-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.js
105 lines (103 loc) · 2.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
103
104
105
const constants = require('./constants.json');
/*
-32700 Parse error Invalid JSON was received by the server.
-32600 Invalid Request The JSON sent is not a valid Request object.
-32601 Method not found The method does not exist / is not available.
-32602 Invalid params Invalid method parameter(s).
-32603 Internal error Internal JSON-RPC error.
-32000 to -32099 Server error Reserved for implementation-defined server-errors.
*/
module.exports = {
rpc: {
PARSE: (id=null) => ({
jsonrpc: constants.JSON_RPC_VERSION,
error: {
code: -32700,
message: 'Parse error'
},
id
}),
INVALID_REQUEST: (id=null) => ({
jsonrpc: constants.JSON_RPC_VERSION,
error: {
code: -32600,
message: 'Invalid request'
},
id
}),
METHOD_NOT_FOUND: (id=null) => ({
jsonrpc: constants.JSON_RPC_VERSION,
error: {
code: -32601,
message: 'Method not found'
},
id
}),
INVALID_PARAMS: (id=null) => ({
jsonrpc: constants.JSON_RPC_VERSION,
error: {
code: -32602,
message: 'Invalid params'
},
id
}),
INTERNAL_ERROR: (id=null) => ({
jsonrpc: constants.JSON_RPC_VERSION,
error: {
code: -32603,
message: 'Internal error'
},
id
}),
METHOD_ERROR: (id=null) => ({
jsonrpc: constants.JSON_RPC_VERSION,
error: {
code: -32000,
message: 'Method encountered an error'
},
id
})
},
internal: {
IN_STREAM_CLOSED: error => ({
code: 1,
message: 'In stream closed unexpectedly',
error
}),
OUT_STREAM_CLOSED: error => ({
code: 2,
message: 'Out stream closed unexpectedly',
error
}),
IN_STREAM_ERROR: error => ({
code: 3,
message: 'In stream threw an error',
error
}),
OUT_STREAM_ERROR: error => ({
code: 4,
message: 'Out stream threw an error',
error
}),
INVALID_PARAMS: error => ({
code: 5,
message: 'Invalid params',
error
}),
INVALID_METHOD: error => ({
code: 6,
message: 'Invalid method name',
error
}),
INVALID_LISTENER: error => ({
code: 7,
message: 'Invalid listener',
error
}),
INVALID_BATCH: error => ({
code: 8,
message: 'Invalid batch',
error
})
}
};