-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
40 lines (35 loc) · 1002 Bytes
/
index.ts
File metadata and controls
40 lines (35 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as util from './lib';
export class Herror extends Error {
override stack!: string;
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, Herror.prototype);
this.name = 'Herror';
Error.captureStackTrace(this, Herror);
this.stack = util.formatStack(this.stack ?? '');
}
}
const prepare = Error.prepareStackTrace;
/**
* If `flag` is truthy or `undefined`, makes all stack traces use
* `<module>@<version>` instead of `node_modules/<module>`.
* If `flag` is falsy, reverts to the default stack format.
*/
export function global(flag?: boolean): void {
if (flag === undefined || Boolean(flag)) {
Error.prepareStackTrace = function (
err: Error,
stack: NodeJS.CallSite[]
): string {
return (
'Error:' +
err.message +
'\n' +
util.formatStack(stack.join('\n at '))
);
};
} else {
Error.prepareStackTrace = prepare;
}
}
export { npmize, formatStack } from './lib';