-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherror_messages.go
More file actions
35 lines (30 loc) · 1.28 KB
/
error_messages.go
File metadata and controls
35 lines (30 loc) · 1.28 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
package jrm1
import "fmt"
// errorMessages is a mapping of built-in RPC error messages by their error
// code.
var errorMessages map[RpcErrorCode]RpcErrorMessage
// initErrorMessages creates a mapping of built-in RPC error messages by their
// error code.
func initErrorMessages() {
errorMessages = map[RpcErrorCode]RpcErrorMessage{
RpcErrorCode_RequestIsNotReadable: RpcErrorMsg_RequestIsNotReadable,
RpcErrorCode_InvalidRequest: RpcErrorMsg_InvalidRequest,
RpcErrorCode_UnsupportedProtocol: RpcErrorMsg_UnsupportedProtocol,
RpcErrorCode_UnknownMethod: RpcErrorMsg_UnknownMethod,
RpcErrorCode_InvalidParameters: RpcErrorMsg_InvalidParameters,
RpcErrorCode_InternalRpcError: RpcErrorMsg_InternalRpcError,
RpcErrorCode_ReservedForFuture_1: RpcErrorMsg_ReservedForFuture_1,
RpcErrorCode_ReservedForFuture_2: RpcErrorMsg_ReservedForFuture_2,
RpcErrorCode_ReservedForFuture_3: RpcErrorMsg_ReservedForFuture_3,
}
}
// findMessageForErrorCode gets an error message from the map of built-in
// error messages by its error code.
func findMessageForErrorCode(code RpcErrorCode) (message RpcErrorMessage, err error) {
var ok bool
message, ok = errorMessages[code]
if !ok {
return RpcErrorMsg_Empty, fmt.Errorf(ErrFUnknownErrorCode, code)
}
return message, nil
}