• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

panates / jsopen-objects / 24282533777

11 Apr 2026 12:31PM UTC coverage: 93.857% (+0.4%) from 93.463%
24282533777

push

github

erayhanoglu
2.2.1

134 of 150 branches covered (89.33%)

Branch coverage included in aggregate %.

523 of 550 relevant lines covered (95.09%)

26.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.63
/src/update-error-message.ts
1
/**
1✔
2
 * Updates the error message and stack trace at sametime.
1✔
3
 * @param err
1✔
4
 * @param newMessage
1✔
5
 */
1✔
6
export function updateErrorMessage(err: Error, newMessage: string) {
1✔
7
  err.message = String(newMessage);
2✔
8
  const stack = typeof err.stack === 'string' ? err.stack : null;
2!
9
  if (!stack) return err;
2!
10
  const name = err.name || 'Error';
2!
11
  const lines = stack.split('\n');
2✔
12
  const firstFrameIdx = lines.findIndex(l => /^\s*at\s+/.test(l));
2✔
13
  if (firstFrameIdx === -1) {
2!
14
    const msgLines = String(newMessage).split(/\r?\n/);
×
15
    lines[0] = `${name}: ${msgLines[0] ?? ''}`;
×
16
    lines.splice(1, 0, ...msgLines.slice(1));
×
17
    err.stack = lines.join('\n');
×
18
    return err;
×
19
  }
×
20
  const frameLines = lines.slice(firstFrameIdx);
2✔
21
  const msgLines = String(newMessage).split(/\r?\n/);
2✔
22
  const newHead = [`${name}: ${msgLines[0] ?? ''}`, ...msgLines.slice(1)];
2!
23
  err.stack = [...newHead, ...frameLines].join('\n');
2✔
24
  return err;
2✔
25
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc