diff options
author | Bas van Kervel <bas@ethdev.com> | 2015-06-16 19:07:13 +0800 |
---|---|---|
committer | Bas van Kervel <bas@ethdev.com> | 2015-06-22 14:54:21 +0800 |
commit | fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2 (patch) | |
tree | 58af87ef1e8c78cfb05a6b756ad5e0b283590a0f /rpc/shared | |
parent | 60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17 (diff) | |
download | dexon-fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2.tar dexon-fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2.tar.gz dexon-fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2.tar.bz2 dexon-fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2.tar.lz dexon-fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2.tar.xz dexon-fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2.tar.zst dexon-fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2.zip |
added comms http
Diffstat (limited to 'rpc/shared')
-rw-r--r-- | rpc/shared/types.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/rpc/shared/types.go b/rpc/shared/types.go index 6a29fa88e..dd38a4559 100644 --- a/rpc/shared/types.go +++ b/rpc/shared/types.go @@ -42,6 +42,18 @@ type ErrorObject struct { // Data interface{} `json:"data"` } +// Create RPC error response, this allows for custom error codes +func NewRpcErrorResponse(id interface{}, jsonrpcver string, errCode int, err error) *interface{} { + var response interface{} + + jsonerr := &ErrorObject{errCode, err.Error()} + response = ErrorResponse{Jsonrpc: jsonrpcver, Id: id, Error: jsonerr} + + glog.V(logger.Detail).Infof("Generated error response: %s", response) + return &response +} + +// Create RPC response func NewRpcResponse(id interface{}, jsonrpcver string, reply interface{}, err error) *interface{} { var response interface{} |