forked from madkarmaa/results-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.ts
More file actions
30 lines (27 loc) · 786 Bytes
/
Copy patherrors.ts
File metadata and controls
30 lines (27 loc) · 786 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
export class PanicError extends Error {
constructor(message: string, options?: ErrorOptions) {
super(message, options);
this.name = 'PanicError';
}
}
export class InvalidArgumentError extends Error {
constructor(message: string) {
super(message);
this.name = 'InvalidArgumentError';
}
}
export class FlattenError extends InvalidArgumentError {
constructor(message: string) {
super(message);
this.name = 'FlattenError';
}
}
export function assertValueIsNotMissing<T>(
value: T | null | undefined,
message?: string
): asserts value is T {
if (value === null || value === undefined)
throw new InvalidArgumentError(
message || 'Expected a non-null, non-undefined value'
);
}