aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/shared
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2015-06-16 19:07:13 +0800
committerBas van Kervel <bas@ethdev.com>2015-06-22 14:54:21 +0800
commitfd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2 (patch)
tree58af87ef1e8c78cfb05a6b756ad5e0b283590a0f /rpc/shared
parent60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17 (diff)
downloadgo-tangerine-fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2.tar.gz
go-tangerine-fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2.tar.zst
go-tangerine-fd764d4ff7bd7e75dfdd7f733f50dd3805d4b3f2.zip
added comms http
Diffstat (limited to 'rpc/shared')
-rw-r--r--rpc/shared/types.go12
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{}