-
-
Notifications
You must be signed in to change notification settings - Fork 574
/
DetailedError.ts
40 lines (37 loc) · 1 KB
/
DetailedError.ts
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 type {LogPayload} from '../app';
type DetailedErrorProps = Pick<
LogPayload,
'message' | 'remarks' | 'object' | 'durationMs' | 'inspect'
>;
export class DetailedError extends Error {
/**
* {@inheritDoc app.LogPayload.message}
*/
public readonly remarks?: string;
/**
* {@inheritDoc app.LogPayload.object}
*/
public readonly object?: any;
/**
* {@inheritDoc app.LogPayload.durationMs}
*/
public readonly durationMs?: number;
/**
* {@inheritDoc app.LogPayload.inspect}
*/
public readonly inspect?: string;
public constructor(message: string, remarks?: string);
public constructor(props: DetailedErrorProps);
public constructor(props: string | DetailedErrorProps, remarks?: string) {
if (typeof props === 'string') {
super(props);
this.remarks = remarks;
} else {
super(props.message);
this.remarks = props.remarks;
this.object = props.object;
this.durationMs = props.durationMs;
this.inspect = props.inspect;
}
}
}