aboutsummaryrefslogtreecommitdiff
path: root/rpc/errors.go
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/errors.go')
-rw-r--r--rpc/errors.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/rpc/errors.go b/rpc/errors.go
index a18c712..71a7168 100644
--- a/rpc/errors.go
+++ b/rpc/errors.go
@@ -50,7 +50,7 @@ func (e Error) Error() string {
return fmt.Sprintf("jsonrpc2 error: code: %d message: %s", e.Code, e.Message)
}
-func NewError(code int) Error {
+func ErrorFromCode(code int) Error {
if _, ok := errorMap[code]; ok {
return Error{
Code: code,
@@ -59,3 +59,13 @@ func NewError(code int) Error {
}
return Error{Code: code}
}
+
+func NewError(message string, code int) Error {
+ if code == 0 {
+ code = ErrUser
+ }
+ return Error{
+ Code: code,
+ Message: message,
+ }
+}