|
|
@ -20,6 +20,8 @@ import org.hyperledger.besu.plugin.services.rpc.RpcMethodError; |
|
|
|
public class PluginRpcEndpointException extends RuntimeException { |
|
|
|
public class PluginRpcEndpointException extends RuntimeException { |
|
|
|
/** The error */ |
|
|
|
/** The error */ |
|
|
|
private final RpcMethodError rpcMethodError; |
|
|
|
private final RpcMethodError rpcMethodError; |
|
|
|
|
|
|
|
/** The data associated with the exception */ |
|
|
|
|
|
|
|
private final String data; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructs a new PluginRpcEndpointException exception with the specified error. |
|
|
|
* Constructs a new PluginRpcEndpointException exception with the specified error. |
|
|
@ -27,20 +29,18 @@ public class PluginRpcEndpointException extends RuntimeException { |
|
|
|
* @param rpcMethodError the error. |
|
|
|
* @param rpcMethodError the error. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public PluginRpcEndpointException(final RpcMethodError rpcMethodError) { |
|
|
|
public PluginRpcEndpointException(final RpcMethodError rpcMethodError) { |
|
|
|
super(); |
|
|
|
this(rpcMethodError, null); |
|
|
|
this.rpcMethodError = rpcMethodError; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructs a new PluginRpcEndpointException exception with the specified error and message. |
|
|
|
* Constructs a new PluginRpcEndpointException exception with the specified error and message. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param rpcMethodError the error. |
|
|
|
* @param rpcMethodError the error. |
|
|
|
* @param message the detail message (which is saved for later retrieval by the {@link |
|
|
|
* @param data the data associated with the exception that could be parsed to extract more |
|
|
|
* #getMessage()} method). |
|
|
|
* information to return in the error response. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public PluginRpcEndpointException(final RpcMethodError rpcMethodError, final String message) { |
|
|
|
public PluginRpcEndpointException(final RpcMethodError rpcMethodError, final String data) { |
|
|
|
super(message); |
|
|
|
this(rpcMethodError, data, null); |
|
|
|
this.rpcMethodError = rpcMethodError; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -48,16 +48,17 @@ public class PluginRpcEndpointException extends RuntimeException { |
|
|
|
* cause. |
|
|
|
* cause. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param rpcMethodError the error. |
|
|
|
* @param rpcMethodError the error. |
|
|
|
* @param message the detail message (which is saved for later retrieval by the {@link |
|
|
|
* @param data the data associated with the exception that could be parsed to extract more |
|
|
|
* #getMessage()} method). |
|
|
|
* information to return in the error response. |
|
|
|
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). |
|
|
|
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). |
|
|
|
* (A {@code null} value is permitted, and indicates that the cause is nonexistent or |
|
|
|
* (A {@code null} value is permitted, and indicates that the cause is nonexistent or |
|
|
|
* unknown.) |
|
|
|
* unknown.) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public PluginRpcEndpointException( |
|
|
|
public PluginRpcEndpointException( |
|
|
|
final RpcMethodError rpcMethodError, final String message, final Throwable cause) { |
|
|
|
final RpcMethodError rpcMethodError, final String data, final Throwable cause) { |
|
|
|
super(message, cause); |
|
|
|
super(rpcMethodError.getMessage(), cause); |
|
|
|
this.rpcMethodError = rpcMethodError; |
|
|
|
this.rpcMethodError = rpcMethodError; |
|
|
|
|
|
|
|
this.data = data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -68,4 +69,13 @@ public class PluginRpcEndpointException extends RuntimeException { |
|
|
|
public RpcMethodError getRpcMethodError() { |
|
|
|
public RpcMethodError getRpcMethodError() { |
|
|
|
return rpcMethodError; |
|
|
|
return rpcMethodError; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the data associated with the exception |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return data as string, could be null. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public String getData() { |
|
|
|
|
|
|
|
return data; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|