-
Notifications
You must be signed in to change notification settings - Fork 23
/
jssm_error.ts
55 lines (33 loc) · 1.06 KB
/
jssm_error.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { JssmErrorExtendedInfo } from './jssm_types';
class JssmError extends Error {
message : string;
base_message : string;
requested_state : string | undefined;
constructor(machine: any, message: string, JEEI?: JssmErrorExtendedInfo) {
const { requested_state } = (JEEI === undefined)
? { requested_state: undefined }
: JEEI;
const follow_ups = [];
if (machine) {
if (machine.state() !== undefined) { follow_ups.push(`at "${machine.state()}"`); }
}
if (requested_state !== undefined) { follow_ups.push(`requested "${requested_state}"`); }
const complex_msg = `${
(machine?.instance_name() !== undefined)
? `[[${machine.instance_name()}]]: `
: ''
}${
message
}${
follow_ups.length
? ` (${follow_ups.join(', ')})`
: ''
}`;
super(complex_msg);
this.name = 'JssmError';
this.message = complex_msg;
this.base_message = message;
this.requested_state = requested_state;
}
};
export { JssmError };