-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRpcErrorMessage.go
More file actions
42 lines (34 loc) · 1.18 KB
/
Copy pathRpcErrorMessage.go
File metadata and controls
42 lines (34 loc) · 1.18 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
package jrm1
import "errors"
// RPC error messages.
const (
RpcErrorMsg_RequestIsNotReadable = "Request is not readable"
RpcErrorMsg_InvalidRequest = "Invalid request"
RpcErrorMsg_UnsupportedProtocol = "Unsupported protocol"
RpcErrorMsg_UnknownMethod = "Unknown method"
RpcErrorMsg_InvalidParameters = "Invalid parameters"
RpcErrorMsg_InternalRpcError = "Internal RPC error"
//
RpcErrorMsg_ReservedForFuture_1 = "Reserved for future (1)"
RpcErrorMsg_ReservedForFuture_2 = "Reserved for future (2)"
RpcErrorMsg_ReservedForFuture_3 = "Reserved for future (3)"
RpcErrorMsg_Empty = ""
)
const (
ErrErrorMessageIsNotSet = "error message is not set"
)
// RpcErrorMessage is a message for an RPC error.
// It stores some textual description of an error.
type RpcErrorMessage string
// Check performs a basic check – it ensures that message is set, i.e. is not
// empty. This function does not validate correctness of the text.
func (rem RpcErrorMessage) Check() (err error) {
if len(rem) == 0 {
return errors.New(ErrErrorMessageIsNotSet)
}
return nil
}
// String returns RPC error message as a string.
func (rem RpcErrorMessage) String() string {
return string(rem)
}