From 8afd6516e1fce466d11147f9a7391542f548f9e0 Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta <45264458+abdelhamidbakhta@users.noreply.github.com> Date: Tue, 18 Feb 2020 17:56:15 +0100 Subject: [PATCH] Create a custom error when plugin is not found. (#409) Signed-off-by: Abdelhamid Bakhta --- .../jsonrpc/internal/methods/PluginsReloadConfiguration.java | 2 +- .../ethereum/api/jsonrpc/internal/response/JsonRpcError.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginsReloadConfiguration.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginsReloadConfiguration.java index 5c682b6dad..8905def578 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginsReloadConfiguration.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginsReloadConfiguration.java @@ -52,7 +52,7 @@ public class PluginsReloadConfiguration implements JsonRpcMethod { "Plugin cannot be reloaded because no plugin has been registered with specified name: {}.", pluginName); return new JsonRpcErrorResponse( - requestContext.getRequest().getId(), JsonRpcError.INTERNAL_ERROR); + requestContext.getRequest().getId(), JsonRpcError.PLUGIN_NOT_FOUND); } reloadPluginConfig(namedPlugins.get(pluginName)); return new JsonRpcSuccessResponse(requestContext.getRequest().getId()); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java index 5b61f2cfaa..a18159dffb 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java @@ -150,7 +150,10 @@ public enum JsonRpcError { ENCLAVE_PRIVACY_GROUP_MISSING(-50200, "PrivacyGroupNotFound"), ENCLAVE_PRIVACY_QUERY_ERROR(-50200, "PrivacyGroupQueryError"), ENCLAVE_KEYS_CANNOT_DECRYPT_PAYLOAD(-50200, "EnclaveKeysCannotDecryptPayload"), - METHOD_UNIMPLEMENTED(-50200, "MethodUnimplemented"); + METHOD_UNIMPLEMENTED(-50200, "MethodUnimplemented"), + + /** Plugins error */ + PLUGIN_NOT_FOUND(-60000, "Plugin not found"); private final int code; private final String message;