-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
36 lines (29 loc) · 999 Bytes
/
index.d.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
/***********************************************************************************************************************
Example in TypeScript:
import SenseError from '@sense/error';
class ErrorA extends SError {};
class ErrorB extends SError {};
try {
throw new ErrorB();
} catch (e) {
if (e instanceOf ErrorA)
console.log('Error type A');
if (e instanceOf ErrorB)
console.log('Error type B');
}
try {
throw new ErrorA();
} catch (e) {
const errorMap = {
[ErrorA]: () => console.log('Error type A'),
[ErrorB]: () => console.log('Error type B')
};
// Prepare the case that the `errorMap` doesn't have the key about `e`
(errorMap[e] | () => {})();
}
***********************************************************************************************************************/
export default class SenseError extends Error {
constructor(args?: { message?: string, details?: any } | string)
message: string;
details: any;
}