forked from SolidOS/solid-logic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomError.ts
More file actions
29 lines (21 loc) · 862 Bytes
/
CustomError.ts
File metadata and controls
29 lines (21 loc) · 862 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
class CustomError extends Error {
constructor(message?: string) {
super(message)
// see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html
Object.setPrototypeOf(this, new.target.prototype) // restore prototype chain
this.name = new.target.name // stack traces display correctly now
}
}
export class UnauthorizedError extends CustomError {}
export class CrossOriginForbiddenError extends CustomError {}
export class SameOriginForbiddenError extends CustomError {}
export class NotFoundError extends CustomError {}
export class NotEditableError extends CustomError { }
export class WebOperationError extends CustomError {}
export class FetchError extends CustomError {
status: number
constructor(status: number, message?: string) {
super(message)
this.status = status
}
}