-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathunimplemented.ts
More file actions
37 lines (34 loc) · 893 Bytes
/
unimplemented.ts
File metadata and controls
37 lines (34 loc) · 893 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
/**
* Error indicating that this part is unimplemented.
*/
export class UnimplementedError extends Error {
constructor(message = "unimplemented") {
super(message);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, UnimplementedError);
}
this.name = this.constructor.name;
}
}
/**
* Function indicating that this part is unimplemented.
*
* For example, defining a mock object with `unimplemented` function should look like this:
*
* ```ts
* import { unimplemented } from "@core/errorutil/unimplemented";
*
* type Service = {
* get(id: string): Promise<string>;
* set(id: string, item: string): Promise<void>;
* };
*
* const _mock: Service = {
* get: () => unimplemented(),
* set: () => unimplemented(),
* };
* ```
*/
export function unimplemented(message = "unimplemented"): never {
throw new UnimplementedError(message);
}