-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherrors.js
More file actions
78 lines (66 loc) · 1.48 KB
/
errors.js
File metadata and controls
78 lines (66 loc) · 1.48 KB
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
export const ALREADY_CONNECTED = 'Already connected',
NOT_CONNECTED = 'Not connected',
ERR_NETWORK = 'Network Error',
INVALID_ARGUMENTS = 'Check your arguments',
INVALID_ARGUMENT_WITH_CS = (val) => {
return INVALID_ARGUMENTS + ' ' + val
},
NOT_SUBSCRIBED = 'Not subscribed',
ALREADY_SUBSCRIBED = 'Already subscribed',
ADDRESSES_IS_EMPTY = 'Addresses is empty',
BLOCK_NOT_FOUND = 'Block does not exist',
TRANSACTION_TYPE_NOT_VALID = 'Transaction type is not valid',
TRANSACTION_NOT_BROADCAST = 'Transaction can not be broadcast'
export class CopiedError extends Error {
originName
originError
originStack
/**
* @param {Error} err
*/
constructor(err) {
super(err.message)
this.name = 'CopiedError'
this.originName = err.name
this.originError = err
this.stack = err.stack
this.originStack = err.stack
}
}
export class FetchError extends Error {
status = -1
response
originError
/**
* @param {string} message
*/
constructor(message) {
super(message)
this.name = 'FetchError'
}
/**
* @param {number} status
* @return {FetchError}
*/
setStatus(status) {
this.status = status
return this
}
/**
* @deprecated use .setStatus/1
* @param {number} code
* @return {FetchError}
*/
setCode(code) {
this.status = code
return this
}
setResponse(data) {
this.response = data
return this
}
setOriginError(error) {
this.originError = error
return this
}
}