-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy patherrors.js
102 lines (92 loc) · 3.14 KB
/
errors.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
export class HTTPError extends Error {
/**
*
* @param {string} message
* @param {number} [status]
*/
constructor (message, status = 500) {
super(message)
this.name = 'HTTPError'
this.status = status
}
}
export class BadContentTypeError extends HTTPError {
constructor (msg = 'Bad content type header found') {
super(msg, 400)
this.name = 'BadContentType'
this.code = BadContentTypeError.CODE
}
}
BadContentTypeError.CODE = 'ERROR_BAD_CONTENT_TYPE'
export class BadBodyError extends HTTPError {
constructor (msg = 'Bad body received') {
super(msg, 400)
this.name = 'BadBody'
this.code = BadBodyError.CODE
}
}
BadBodyError.CODE = 'ERROR_BAD_BODY'
export class NoInvocationFoundForGivenReceiptError extends HTTPError {
constructor (msg = 'No invocation found for given receipt') {
super(msg, 404)
this.name = 'NoInvocationFoundForGivenReceipt'
this.code = NoInvocationFoundForGivenReceiptError.CODE
}
}
NoInvocationFoundForGivenReceiptError.CODE = 'ERROR_INVOCATION_NOT_FOUND_FOR_RECEIPT'
export class NoCarFoundForGivenReceiptError extends HTTPError {
constructor (msg = 'No car found for given receipt') {
super(msg, 404)
this.name = 'NoCarFoundForGivenReceipt'
this.code = NoCarFoundForGivenReceiptError.CODE
}
}
NoCarFoundForGivenReceiptError.CODE = 'ERROR_CAR_NOT_FOUND_FOR_RECEIPT'
export class NoInvocationFoundForGivenCidError extends HTTPError {
constructor (msg = 'No invocation found for CID') {
super(msg, 404)
this.name = 'NoInvocationFoundForGivenCid'
this.code = NoInvocationFoundForGivenCidError.CODE
}
}
NoInvocationFoundForGivenCidError.CODE = 'ERROR_INVOCATION_NOT_FOUND_FOR_CID'
export class NoDelegationFoundForGivenCidError extends HTTPError {
constructor (msg = 'No delegation found for CID') {
super(msg, 404)
this.name = 'NoDelegationFoundForGivenCid'
this.code = NoDelegationFoundForGivenCidError.CODE
}
}
NoDelegationFoundForGivenCidError.CODE = 'ERROR_DELEGATION_NOT_FOUND_FOR_CID'
export class FailedToDecodeDelegationForGivenCidError extends HTTPError {
constructor (msg = 'Failed to decode delegation with given CID') {
super(msg, 400)
this.name = 'FailedToDecodeDelegationForGivenCid'
this.code = FailedToDecodeDelegationForGivenCidError.CODE
}
}
FailedToDecodeDelegationForGivenCidError.CODE = 'ERROR_DELEGATION_DECODE_FAILED_FOR_CID'
export class NoTokenError extends HTTPError {
constructor (msg = 'No token found in `Authorization: Basic ` header') {
super(msg, 401)
this.name = 'NoToken'
this.code = NoTokenError.CODE
}
}
NoTokenError.CODE = 'ERROR_NO_TOKEN'
export class ExpectedBasicStringError extends HTTPError {
constructor (msg = 'Expected argument to be a string in the `Basic {token}` format') {
super(msg, 407)
this.name = 'ExpectedBasicString'
this.code = ExpectedBasicStringError.CODE
}
}
ExpectedBasicStringError.CODE = 'ERROR_NO_TOKEN'
export class NoValidTokenError extends HTTPError {
constructor (msg = 'Provided token is not valid') {
super(msg, 403)
this.name = 'NoValidToken'
this.code = NoValidTokenError.CODE
}
}
NoValidTokenError.CODE = 'ERROR_NO_VALID_TOKEN'