-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponse.go
35 lines (29 loc) · 1.05 KB
/
response.go
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
package booze
type Error struct {
Code int `json:"code"`
Data interface{} `json:"data,omitempty"`
Message string `json:"message"`
}
func (e Error) Error() string {
return e.Message
}
var (
ParseError = Error{Code: -32700, Message: "parse error"}
SystemError = Error{Code: -32400, Message: "system error"}
InternalError = Error{Code: -32603, Message: "internal error"}
InvalidParams = Error{Code: -32602, Message: "invalid params"}
TransportError = Error{Code: -32300, Message: "transport error"}
InvalidRequest = Error{Code: -32600, Message: "invalid request"}
MethodNotFound = Error{Code: -32601, Message: "method not found"}
ApplicationError = Error{Code: -32500, Message: "application error"}
)
type RPCVersion20 string
func (v RPCVersion20) MarshalJSON() ([]byte, error) {
return []byte(`"2.0"`), nil
}
type Response struct {
ID string `json:"id"`
Error *Error `json:"error,omitempty"`
Result interface{} `json:"result,omitempty"`
RPCVersion RPCVersion20 `json:"jsonrpc"`
}