[jsonrpc-glib] client: add various error enums



commit edb342100f9e83c484c4fd30bbf9b71a692e262a
Author: Christian Hergert <chergert redhat com>
Date:   Wed Dec 27 22:01:25 2017 -0800

    client: add various error enums
    
    These come from the protocol spec at:
    
      https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal
    
    and can be useful to have as constants for applications.

 src/jsonrpc-client.c | 2 +-
 src/jsonrpc-client.h | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/jsonrpc-client.c b/src/jsonrpc-client.c
index 6d3523d..9a618c7 100644
--- a/src/jsonrpc-client.c
+++ b/src/jsonrpc-client.c
@@ -723,7 +723,7 @@ jsonrpc_client_call_read_cb (GObject      *object,
       g_signal_emit (self, signals [HANDLE_CALL], detail, method_name, id, params, &ret);
 
       if (ret == FALSE)
-        jsonrpc_client_reply_error_async (self, id, -32601,
+        jsonrpc_client_reply_error_async (self, id, JSONRPC_CLIENT_ERROR_METHOD_NOT_FOUND,
                                           "The method does not exist or is not available",
                                           NULL, NULL, NULL);
 
diff --git a/src/jsonrpc-client.h b/src/jsonrpc-client.h
index 71c009d..09ad121 100644
--- a/src/jsonrpc-client.h
+++ b/src/jsonrpc-client.h
@@ -28,6 +28,15 @@ G_BEGIN_DECLS
 #define JSONRPC_TYPE_CLIENT  (jsonrpc_client_get_type())
 #define JSONRPC_CLIENT_ERROR (jsonrpc_client_error_quark())
 
+typedef enum
+{
+  JSONRPC_CLIENT_ERROR_PARSE_ERROR      = -32700,
+  JSONRPC_CLIENT_ERROR_INVALID_REQUEST  = -32600,
+  JSONRPC_CLIENT_ERROR_METHOD_NOT_FOUND = -32601,
+  JSONRPC_CLIENT_ERROR_INVALID_PARAMS   = -32602,
+  JSONRPC_CLIENT_ERROR_INTERNAL_ERROR   = -32603,
+} JsonrpcClientError;
+
 G_DECLARE_DERIVABLE_TYPE (JsonrpcClient, jsonrpc_client, JSONRPC, CLIENT, GObject)
 
 struct _JsonrpcClientClass


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]