5098 branch 24 throw checked exception to remove todos (#7481)

* 5098: Add RpcErrorTypes

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

---------

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
Signed-off-by: Matilda-Clerke <matilda.clerke@consensys.net>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/7493/head
Matilda-Clerke 3 months ago committed by GitHub
parent 4c0d7b5dbb
commit 0182252523
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/CliqueGetSigners.java
  2. 3
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/CliqueGetSignersAtHash.java
  3. 3
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/Discard.java
  4. 5
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/Propose.java
  5. 5
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/jsonrpc/AbstractGetSignerMetricsMethod.java
  6. 3
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftDiscardValidatorVote.java
  7. 3
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java
  8. 3
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java
  9. 5
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftProposeValidatorVote.java
  10. 3
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftDiscardValidatorVote.java
  11. 3
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockHash.java
  12. 3
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockNumber.java
  13. 5
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftProposeValidatorVote.java
  14. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/DebugReplayBlock.java
  15. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/JsonRpcRequest.java
  16. 11
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/JsonRpcRequestContext.java
  17. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AbstractTraceByBlock.java
  18. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevel.java
  19. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminGenerateLogBloomCache.java
  20. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminLogsRemoveCache.java
  21. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminLogsRepairCache.java
  22. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminModifyPeer.java
  23. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountAt.java
  24. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountRange.java
  25. 13
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugBatchSendRawTransaction.java
  26. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawBlock.java
  27. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawHeader.java
  28. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawReceipts.java
  29. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawTransaction.java
  30. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHead.java
  31. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBadBlockToFile.java
  32. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBlockToFile.java
  33. 11
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAt.java
  34. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java
  35. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHash.java
  36. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumber.java
  37. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceCall.java
  38. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransaction.java
  39. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCall.java
  40. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthFeeHistory.java
  41. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBalance.java
  42. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByHash.java
  43. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumber.java
  44. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockReceipts.java
  45. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockTransactionCountByHash.java
  46. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockTransactionCountByNumber.java
  47. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetCode.java
  48. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetFilterChanges.java
  49. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetFilterLogs.java
  50. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetLogs.java
  51. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockHash.java
  52. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockNumber.java
  53. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProof.java
  54. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetStorageAt.java
  55. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionByBlockHashAndIndex.java
  56. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionByBlockNumberAndIndex.java
  57. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionByHash.java
  58. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionCount.java
  59. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceipt.java
  60. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetUncleByBlockHashAndIndex.java
  61. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetUncleByBlockNumberAndIndex.java
  62. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetUncleCountByBlockHash.java
  63. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetUncleCountByBlockNumber.java
  64. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthNewFilter.java
  65. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransaction.java
  66. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitHashRate.java
  67. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitWork.java
  68. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthUninstallFilter.java
  69. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/JsonCallParameterUtil.java
  70. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginsReloadConfiguration.java
  71. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceBlock.java
  72. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceCall.java
  73. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceCallMany.java
  74. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceFilter.java
  75. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceGet.java
  76. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceRawTransaction.java
  77. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceReplayBlockTransactions.java
  78. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceTransaction.java
  79. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TxPoolBesuPendingTransactions.java
  80. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/Web3Sha3.java
  81. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineForkchoiceUpdated.java
  82. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayload.java
  83. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java
  84. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeCapabilities.java
  85. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfiguration.java
  86. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1.java
  87. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1.java
  88. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EnginePreparePayloadDebug.java
  89. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerChangeTargetGasLimit.java
  90. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetCoinbase.java
  91. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraData.java
  92. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPrice.java
  93. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFee.java
  94. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddAccountsToAllowlist.java
  95. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlist.java
  96. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromAllowlist.java
  97. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlist.java
  98. 27
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonRpcParameter.java
  99. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/PrivGetFilterChanges.java
  100. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/PrivGetFilterLogs.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -71,7 +72,7 @@ public class CliqueGetSigners implements JsonRpcMethod {
final Optional<BlockParameter> blockParameter;
try {
blockParameter = request.getOptionalParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -71,7 +72,7 @@ public class CliqueGetSignersAtHash implements JsonRpcMethod {
final Hash hash;
try {
hash = request.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}

@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -51,7 +52,7 @@ public class Discard implements JsonRpcMethod {
final Address address;
try {
address = requestContext.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}

@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -53,14 +54,14 @@ public class Propose implements JsonRpcMethod {
final Address address;
try {
address = requestContext.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
final Boolean auth;
try {
auth = requestContext.getRequiredParameter(1, Boolean.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid auth parameter (index 1)", RpcErrorType.INVALID_PROPOSAL_PARAMS, e);
}

@ -20,6 +20,7 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -70,14 +71,14 @@ public abstract class AbstractGetSignerMetricsMethod {
final Optional<BlockParameter> startBlockParameter;
try {
startBlockParameter = requestContext.getOptionalParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid start block parameter (index 0)", RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS, e);
}
final Optional<BlockParameter> endBlockParameter;
try {
endBlockParameter = requestContext.getOptionalParameter(1, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid end block parameter (index 1)", RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS, e);
}

@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -55,7 +56,7 @@ public class IbftDiscardValidatorVote implements JsonRpcMethod {
final Address validatorAddress;
try {
validatorAddress = requestContext.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid validator address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -66,7 +67,7 @@ public class IbftGetValidatorsByBlockHash implements JsonRpcMethod {
final Hash hash;
try {
hash = request.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonR
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.AbstractBlockParameterMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -54,7 +55,7 @@ public class IbftGetValidatorsByBlockNumber extends AbstractBlockParameterMethod
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -56,14 +57,14 @@ public class IbftProposeValidatorVote implements JsonRpcMethod {
final Address validatorAddress;
try {
validatorAddress = requestContext.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
final Boolean add;
try {
add = requestContext.getRequiredParameter(1, Boolean.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid vote type parameter (index 1)", RpcErrorType.INVALID_VOTE_TYPE_PARAMS, e);
}

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -53,7 +54,7 @@ public class QbftDiscardValidatorVote implements JsonRpcMethod {
final Address validatorAddress;
try {
validatorAddress = requestContext.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid validator address parameter (index 0)",
RpcErrorType.INVALID_ADDRESS_PARAMS,

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -67,7 +68,7 @@ public class QbftGetValidatorsByBlockHash implements JsonRpcMethod {
final Hash hash;
try {
hash = request.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}

@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonR
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.AbstractBlockParameterMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -54,7 +55,7 @@ public class QbftGetValidatorsByBlockNumber extends AbstractBlockParameterMethod
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -54,7 +55,7 @@ public class QbftProposeValidatorVote implements JsonRpcMethod {
final Address validatorAddress;
try {
validatorAddress = requestContext.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid validator address parameter (index 0)",
RpcErrorType.INVALID_ADDRESS_PARAMS,
@ -63,7 +64,7 @@ public class QbftProposeValidatorVote implements JsonRpcMethod {
final Boolean add;
try {
add = requestContext.getRequiredParameter(1, Boolean.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid vote type parameter (index 1)", RpcErrorType.INVALID_VOTE_TYPE_PARAMS, e);
}

@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.AbstractBlockParameterMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -60,7 +61,7 @@ public class DebugReplayBlock extends AbstractBlockParameterMethod {
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.util.Arrays;
@ -132,15 +133,18 @@ public class JsonRpcRequest {
return Objects.hash(id, method, Arrays.hashCode(params), version, isNotification);
}
public <T> T getRequiredParameter(final int index, final Class<T> paramClass) {
public <T> T getRequiredParameter(final int index, final Class<T> paramClass)
throws JsonRpcParameterException {
return parameterAccessor.required(params, index, paramClass);
}
public <T> Optional<T> getOptionalParameter(final int index, final Class<T> paramClass) {
public <T> Optional<T> getOptionalParameter(final int index, final Class<T> paramClass)
throws JsonRpcParameterException {
return parameterAccessor.optional(params, index, paramClass);
}
public <T> Optional<List<T>> getOptionalList(final int index, final Class<T> paramClass) {
public <T> Optional<List<T>> getOptionalList(final int index, final Class<T> paramClass)
throws JsonRpcParameterException {
return parameterAccessor.optionalList(params, index, paramClass);
}

@ -14,6 +14,8 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@ -61,15 +63,18 @@ public class JsonRpcRequestContext {
return user;
}
public <T> T getRequiredParameter(final int index, final Class<T> paramClass) {
public <T> T getRequiredParameter(final int index, final Class<T> paramClass)
throws JsonRpcParameterException {
return jsonRpcRequest.getRequiredParameter(index, paramClass);
}
public <T> Optional<T> getOptionalParameter(final int index, final Class<T> paramClass) {
public <T> Optional<T> getOptionalParameter(final int index, final Class<T> paramClass)
throws JsonRpcParameterException {
return jsonRpcRequest.getOptionalParameter(index, paramClass);
}
public <T> Optional<List<T>> getOptionalList(final int index, final Class<T> listOf) {
public <T> Optional<List<T>> getOptionalList(final int index, final Class<T> listOf)
throws JsonRpcParameterException {
return jsonRpcRequest.getOptionalList(index, listOf);
}

@ -19,6 +19,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.Trac
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -67,7 +68,7 @@ public abstract class AbstractTraceByBlock extends AbstractBlockParameterMethod
final Optional<BlockParameter> maybeBlockParameter;
try {
maybeBlockParameter = request.getOptionalParameter(2, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 2)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -47,7 +48,7 @@ public class AdminChangeLogLevel implements JsonRpcMethod {
final String logLevel;
try {
logLevel = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid log level parameter (index 0)", RpcErrorType.INVALID_LOG_LEVEL_PARAMS, e);
}
@ -58,7 +59,7 @@ public class AdminChangeLogLevel implements JsonRpcMethod {
final Optional<String[]> optionalLogFilters;
try {
optionalLogFilters = requestContext.getOptionalParameter(1, String[].class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid log filter parameters (index 1)", RpcErrorType.INVALID_LOG_FILTER_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -43,7 +44,7 @@ public class AdminGenerateLogBloomCache implements JsonRpcMethod {
final Optional<BlockParameter> startBlockParam;
try {
startBlockParam = requestContext.getOptionalParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid start block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -60,7 +61,7 @@ public class AdminGenerateLogBloomCache implements JsonRpcMethod {
final Optional<BlockParameter> stopBlockParam;
try {
stopBlockParam = requestContext.getOptionalParameter(1, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid stop block parameter (index 1)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -46,14 +47,14 @@ public class AdminLogsRemoveCache implements JsonRpcMethod {
final Optional<BlockParameter> startBlockParameter;
try {
startBlockParameter = requestContext.getOptionalParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid start block parameter (index 0)", RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS, e);
}
final Optional<BlockParameter> stopBlockParameter;
try {
stopBlockParameter = requestContext.getOptionalParameter(1, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid stop block parameter (index 1)", RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS, e);
}

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -43,7 +44,7 @@ public class AdminLogsRepairCache implements JsonRpcMethod {
final Optional<Long> blockNumber;
try {
blockNumber = requestContext.getOptionalParameter(0, Long.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block number parameter (index 0)", RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS, e);
}

@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -65,7 +66,7 @@ public abstract class AdminModifyPeer implements JsonRpcMethod {
} catch (final P2PDisabledException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_ENODE_PARAMS);
}

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
@ -69,7 +70,7 @@ public class DebugAccountAt extends AbstractBlockParameterOrBlockHashMethod {
final JsonRpcRequestContext requestContext) {
try {
return requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -81,7 +82,7 @@ public class DebugAccountAt extends AbstractBlockParameterOrBlockHashMethod {
final Integer txIndex;
try {
txIndex = requestContext.getRequiredParameter(1, Integer.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction index parameter (index 1)",
RpcErrorType.INVALID_TRANSACTION_INDEX_PARAMS,
@ -90,7 +91,7 @@ public class DebugAccountAt extends AbstractBlockParameterOrBlockHashMethod {
final Address address;
try {
address = requestContext.getRequiredParameter(2, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 2)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}

@ -19,6 +19,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -62,7 +63,7 @@ public class DebugAccountRange implements JsonRpcMethod {
try {
blockParameterOrBlockHash =
requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter or block hash parameter (index 0)",
RpcErrorType.INVALID_BLOCK_PARAMS,
@ -71,14 +72,14 @@ public class DebugAccountRange implements JsonRpcMethod {
final String addressHash;
try {
addressHash = requestContext.getRequiredParameter(2, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address hash parameter (index 2)", RpcErrorType.INVALID_ADDRESS_HASH_PARAMS, e);
}
final int maxResults;
try {
maxResults = requestContext.getRequiredParameter(3, Integer.TYPE);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid max results parameter (index 3)", RpcErrorType.INVALID_MAX_RESULTS_PARAMS, e);
}

@ -16,8 +16,11 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.util.DomainObjectDecodeUtils;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
@ -56,9 +59,15 @@ public class DebugBatchSendRawTransaction implements JsonRpcMethod {
final List<ExecutionStatus> executionStatuses = new ArrayList<>();
IntStream.range(0, requestContext.getRequest().getParamLength())
.forEach(
i ->
i -> {
try {
executionStatuses.add(
process(i, requestContext.getRequiredParameter(i, String.class))));
process(i, requestContext.getRequiredParameter(i, String.class)));
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid parameter (index " + i + ")", RpcErrorType.INVALID_PARAMS, e);
}
});
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), executionStatuses);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -40,7 +41,7 @@ public class DebugGetRawBlock extends AbstractBlockParameterMethod {
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -40,7 +41,7 @@ public class DebugGetRawHeader extends AbstractBlockParameterMethod {
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
@ -44,7 +45,7 @@ public class DebugGetRawReceipts extends AbstractBlockParameterOrBlockHashMethod
final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -43,7 +44,7 @@ public class DebugGetRawTransaction implements JsonRpcMethod {
final Hash txHash;
try {
txHash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction hash parameter (index 0)",
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,

@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -47,7 +48,7 @@ public class DebugSetHead extends AbstractBlockParameterMethod {
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@ -56,14 +57,14 @@ public class DebugStandardTraceBadBlockToFile extends DebugStandardTraceBlockToF
final Hash blockHash;
try {
blockHash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
final Optional<TransactionTraceParams> transactionTraceParams;
try {
transactionTraceParams = requestContext.getOptionalParameter(1, TransactionTraceParams.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction trace parameters (index 1)",
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,

@ -20,6 +20,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer;
@ -63,14 +64,14 @@ public class DebugStandardTraceBlockToFile implements JsonRpcMethod {
final Hash blockHash;
try {
blockHash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
final Optional<TransactionTraceParams> transactionTraceParams;
try {
transactionTraceParams = requestContext.getOptionalParameter(1, TransactionTraceParams.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction trace parameters (index 1)",
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockReplay;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer.TraceableState;
@ -73,14 +74,14 @@ public class DebugStorageRangeAt implements JsonRpcMethod {
try {
blockParameterOrBlockHash =
requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
final int transactionIndex;
try {
transactionIndex = requestContext.getRequiredParameter(1, Integer.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction index parameter (index 1)",
RpcErrorType.INVALID_TRANSACTION_INDEX_PARAMS,
@ -89,21 +90,21 @@ public class DebugStorageRangeAt implements JsonRpcMethod {
final Address accountAddress;
try {
accountAddress = requestContext.getRequiredParameter(2, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid account address parameter (index 2)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
final Hash startKey;
try {
startKey = Hash.fromHexStringLenient(requestContext.getRequiredParameter(3, String.class));
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid data start hash parameter (index 3)", RpcErrorType.INVALID_DATA_HASH_PARAMS, e);
}
final int limit;
try {
limit = requestContext.getRequiredParameter(4, Integer.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid limit parameter (index 4)", RpcErrorType.INVALID_TRANSACTION_LIMIT_PARAMS, e);
}

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
@ -65,15 +66,15 @@ public class DebugTraceBlock implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String input = requestContext.getRequiredParameter(0, String.class);
final Block block;
try {
final String input = requestContext.getRequiredParameter(0, String.class);
block = Block.readFrom(RLP.input(Bytes.fromHexString(input)), this.blockHeaderFunctions);
} catch (final RLPException e) {
LOG.debug("Failed to parse block RLP (index 0)", e);
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_BLOCK_PARAMS);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block params (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -84,7 +85,7 @@ public class DebugTraceBlock implements JsonRpcMethod {
.getOptionalParameter(1, TransactionTraceParams.class)
.map(TransactionTraceParams::traceOptions)
.orElse(TraceOptions.DEFAULT);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction trace parameter (index 1)",
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
@ -55,7 +56,7 @@ public class DebugTraceBlockByHash implements JsonRpcMethod {
final Hash blockHash;
try {
blockHash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
@ -66,7 +67,7 @@ public class DebugTraceBlockByHash implements JsonRpcMethod {
.getOptionalParameter(1, TransactionTraceParams.class)
.map(TransactionTraceParams::traceOptions)
.orElse(TraceOptions.DEFAULT);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction trace parameter (index 1)",
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
@ -51,7 +52,7 @@ public class DebugTraceBlockByNumber extends AbstractBlockParameterMethod {
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -68,7 +69,7 @@ public class DebugTraceBlockByNumber extends AbstractBlockParameterMethod {
.getOptionalParameter(1, TransactionTraceParams.class)
.map(TransactionTraceParams::traceOptions)
.orElse(TraceOptions.DEFAULT);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction trace parameter (index 1)",
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
@ -60,7 +61,7 @@ public class DebugTraceCall extends AbstractTraceCall {
.getOptionalParameter(2, TransactionTraceParams.class)
.map(TransactionTraceParams::traceOptions)
.orElse(TraceOptions.DEFAULT);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction trace parameter (index 2)",
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,
@ -73,7 +74,7 @@ public class DebugTraceCall extends AbstractTraceCall {
final Optional<BlockParameter> maybeBlockParameter;
try {
maybeBlockParameter = request.getOptionalParameter(1, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 1)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer;
@ -53,7 +54,7 @@ public class DebugTraceTransaction implements JsonRpcMethod {
final Hash hash;
try {
hash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction hash parameter (index 0)",
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
@ -69,7 +70,7 @@ public class DebugTraceTransaction implements JsonRpcMethod {
.getOptionalParameter(1, TransactionTraceParams.class)
.map(TransactionTraceParams::traceOptions)
.orElse(TraceOptions.DEFAULT);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction trace parameter (index 1)",
RpcErrorType.INVALID_TRANSACTION_TRACE_PARAMS,

@ -25,6 +25,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -60,7 +61,7 @@ public class EthCall extends AbstractBlockParameterOrBlockHashMethod {
final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(1, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameters (index 1)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedIntParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -91,7 +92,7 @@ public class EthFeeHistory implements JsonRpcMethod {
final int blockCount;
try {
blockCount = request.getRequiredParameter(0, UnsignedIntParameter.class).getValue();
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block count parameter (index 0)", RpcErrorType.INVALID_BLOCK_COUNT_PARAMS, e);
}
@ -101,7 +102,7 @@ public class EthFeeHistory implements JsonRpcMethod {
final BlockParameter highestBlock;
try {
highestBlock = request.getRequiredParameter(1, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid highest block parameter (index 1)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -109,7 +110,7 @@ public class EthFeeHistory implements JsonRpcMethod {
final Optional<List<Double>> maybeRewardPercentiles;
try {
maybeRewardPercentiles = request.getOptionalParameter(2, Double[].class).map(Arrays::asList);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid reward percentiles parameter (index 2)",
RpcErrorType.INVALID_REWARD_PERCENTILES_PARAMS,

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -45,7 +46,7 @@ public class EthGetBalance extends AbstractBlockParameterOrBlockHashMethod {
final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(1, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 1)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -56,7 +57,7 @@ public class EthGetBalance extends AbstractBlockParameterOrBlockHashMethod {
final Address address;
try {
address = request.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -64,7 +65,7 @@ public class EthGetBlockByHash implements JsonRpcMethod {
final Hash hash;
try {
hash = request.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
@ -95,7 +96,7 @@ public class EthGetBlockByHash implements JsonRpcMethod {
private boolean isCompleteTransactions(final JsonRpcRequestContext requestContext) {
try {
return requestContext.getRequiredParameter(1, Boolean.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid return complete transaction parameter (index 1)",
RpcErrorType.INVALID_RETURN_COMPLETE_TRANSACTION_PARAMS,

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory;
@ -66,7 +67,7 @@ public class EthGetBlockByNumber extends AbstractBlockParameterMethod {
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -126,7 +127,7 @@ public class EthGetBlockByNumber extends AbstractBlockParameterMethod {
private boolean isCompleteTransactions(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(1, Boolean.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid return complete transaction parameter (index 1)",
RpcErrorType.INVALID_RETURN_COMPLETE_TRANSACTION_PARAMS,

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockReceiptsResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.TransactionReceiptResult;
@ -57,7 +58,7 @@ public class EthGetBlockReceipts extends AbstractBlockParameterOrBlockHashMethod
final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameters (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -42,7 +43,7 @@ public class EthGetBlockTransactionCountByHash implements JsonRpcMethod {
final Hash hash;
try {
hash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block header hash parameter (index 0)",
RpcErrorType.INVALID_BLOCK_HASH_PARAMS,

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -37,7 +38,7 @@ public class EthGetBlockTransactionCountByNumber extends AbstractBlockParameterM
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameters (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -47,7 +48,7 @@ public class EthGetCode extends AbstractBlockParameterOrBlockHashMethod {
final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(1, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 1)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -58,7 +59,7 @@ public class EthGetCode extends AbstractBlockParameterOrBlockHashMethod {
final Address address;
try {
address = request.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -47,7 +48,7 @@ public class EthGetFilterChanges implements JsonRpcMethod {
final String filterId;
try {
filterId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid filter ID parameter (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -45,7 +46,7 @@ public class EthGetFilterLogs implements JsonRpcMethod {
final String filterId;
try {
filterId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid filter ID parameter (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -55,7 +56,7 @@ public class EthGetLogs implements JsonRpcMethod {
final FilterParameter filter;
try {
filter = requestContext.getRequiredParameter(0, FilterParameter.class);
} catch (Exception e) {
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid filter parameter (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}

@ -19,6 +19,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -65,7 +66,7 @@ public class EthGetMinerDataByBlockHash implements JsonRpcMethod {
final Hash hash;
try {
hash = requestContext.getRequest().getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.MinerDataResult;
import org.hyperledger.besu.ethereum.api.query.BlockWithMetadata;
@ -44,7 +45,7 @@ public class EthGetMinerDataByBlockNumber extends AbstractBlockParameterMethod {
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -51,7 +52,7 @@ public class EthGetProof extends AbstractBlockParameterOrBlockHashMethod {
final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(2, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 2)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -64,7 +65,7 @@ public class EthGetProof extends AbstractBlockParameterOrBlockHashMethod {
final Address address;
try {
address = requestContext.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
@ -110,7 +111,7 @@ public class EthGetProof extends AbstractBlockParameterOrBlockHashMethod {
return Arrays.stream(request.getRequiredParameter(1, String[].class))
.map(UInt256::fromHexString)
.collect(Collectors.toList());
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid storage keys parameters (index 1)", RpcErrorType.INVALID_STORAGE_KEYS_PARAMS, e);
}

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UInt256Parameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -41,7 +42,7 @@ public class EthGetStorageAt extends AbstractBlockParameterOrBlockHashMethod {
final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(2, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 2)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -52,14 +53,14 @@ public class EthGetStorageAt extends AbstractBlockParameterOrBlockHashMethod {
final Address address;
try {
address = request.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
final UInt256 position;
try {
position = request.getRequiredParameter(1, UInt256Parameter.class).getValue();
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid position parameter (index 1)", RpcErrorType.INVALID_POSITION_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedIntParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -47,7 +48,7 @@ public class EthGetTransactionByBlockHashAndIndex implements JsonRpcMethod {
final Hash hash;
try {
hash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction hash parameter (index 0)",
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
@ -56,7 +57,7 @@ public class EthGetTransactionByBlockHashAndIndex implements JsonRpcMethod {
final int index;
try {
index = requestContext.getRequiredParameter(1, UnsignedIntParameter.class).getValue();
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction id parameter (index 1)",
RpcErrorType.INVALID_TRANSACTION_ID_PARAMS,

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedIntParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.TransactionCompleteResult;
@ -41,7 +42,7 @@ public class EthGetTransactionByBlockNumberAndIndex extends AbstractBlockParamet
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -53,7 +54,7 @@ public class EthGetTransactionByBlockNumberAndIndex extends AbstractBlockParamet
final int index;
try {
index = request.getRequiredParameter(1, UnsignedIntParameter.class).getValue();
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction index parameter (index 1)",
RpcErrorType.INVALID_TRANSACTION_INDEX_PARAMS,

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -54,7 +55,7 @@ public class EthGetTransactionByHash implements JsonRpcMethod {
final Hash hash;
try {
hash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction hash parameter (index 0)",
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -54,7 +55,7 @@ public class EthGetTransactionCount extends AbstractBlockParameterOrBlockHashMet
final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(1, BlockParameterOrBlockHash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block or block hash parameter (index 1)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -65,7 +66,7 @@ public class EthGetTransactionCount extends AbstractBlockParameterOrBlockHashMet
final Address address;
try {
address = request.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
@ -88,7 +89,7 @@ public class EthGetTransactionCount extends AbstractBlockParameterOrBlockHashMet
final Address address;
try {
address = request.getRequiredParameter(0, Address.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -51,7 +52,7 @@ public class EthGetTransactionReceipt implements JsonRpcMethod {
final Hash hash;
try {
hash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction hash parameter (index 0)",
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedIntParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -49,14 +50,14 @@ public class EthGetUncleByBlockHashAndIndex implements JsonRpcMethod {
final Hash hash;
try {
hash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
final int index;
try {
index = requestContext.getRequiredParameter(1, UnsignedIntParameter.class).getValue();
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block index parameter (index 1)", RpcErrorType.INVALID_BLOCK_INDEX_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedIntParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResult;
@ -39,7 +40,7 @@ public class EthGetUncleByBlockNumberAndIndex extends AbstractBlockParameterMeth
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -51,7 +52,7 @@ public class EthGetUncleByBlockNumberAndIndex extends AbstractBlockParameterMeth
final int index;
try {
index = request.getRequiredParameter(1, UnsignedIntParameter.class).getValue();
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block index (index 1)", RpcErrorType.INVALID_BLOCK_INDEX_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -42,7 +43,7 @@ public class EthGetUncleCountByBlockHash implements JsonRpcMethod {
final Hash hash;
try {
hash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}

@ -16,7 +16,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -33,7 +36,12 @@ public class EthGetUncleCountByBlockNumber extends AbstractBlockParameterMethod
@Override
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
return request.getRequiredParameter(0, BlockParameter.class);
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}
@Override

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -42,7 +43,7 @@ public class EthNewFilter implements JsonRpcMethod {
final FilterParameter filter;
try {
filter = requestContext.getRequiredParameter(0, FilterParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid filter paramters (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -72,7 +73,7 @@ public class EthSendRawTransaction implements JsonRpcMethod {
final String rawTransaction;
try {
rawTransaction = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction parameters (index 0)", RpcErrorType.INVALID_TRANSACTION_PARAMS, e);
}

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -42,14 +43,14 @@ public class EthSubmitHashRate implements JsonRpcMethod {
final String hashRate;
try {
hashRate = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid hash rate parameter (index 0)", RpcErrorType.INVALID_HASH_RATE_PARAMS, e);
}
final String id;
try {
id = requestContext.getRequiredParameter(1, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid sealer ID parameter (index 1)", RpcErrorType.INVALID_SEALER_ID_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -54,21 +55,21 @@ public class EthSubmitWork implements JsonRpcMethod {
try {
nonce =
Bytes.fromHexString(requestContext.getRequiredParameter(0, String.class)).getLong(0);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid nonce parameter (index 0)", RpcErrorType.INVALID_NONCE_PARAMS, e);
}
Hash mixHash;
try {
mixHash = requestContext.getRequiredParameter(2, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid mix hash parameter (index 2)", RpcErrorType.INVALID_MIX_HASH_PARAMS, e);
}
Bytes powHash;
try {
powHash = Bytes.fromHexString(requestContext.getRequiredParameter(1, String.class));
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid PoW hash parameter (index 1)", RpcErrorType.INVALID_POW_HASH_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -40,7 +41,7 @@ public class EthUninstallFilter implements JsonRpcMethod {
final String filterId;
try {
filterId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid filter ID parameter (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
public class JsonCallParameterUtil {
@ -27,7 +28,7 @@ public class JsonCallParameterUtil {
final JsonCallParameter callParams;
try {
callParams = request.getRequiredParameter(0, JsonCallParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid call parameters (index 0)", RpcErrorType.INVALID_CALL_PARAMS);
}

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -55,7 +56,7 @@ public class PluginsReloadConfiguration implements JsonRpcMethod {
}
reloadPluginConfig(namedPlugins.get(pluginName));
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVAlID_PLUGIN_NAME_PARAMS);
}

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -72,7 +73,7 @@ public class TraceBlock extends AbstractBlockParameterMethod {
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -19,6 +19,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErr
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@ -60,7 +61,7 @@ public class TraceCall extends AbstractTraceCall {
final JsonRpcRequestContext requestContext) {
try {
return requestContext.getRequiredParameter(1, TraceTypeParameter.class).getTraceTypes();
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid trace type parameter (index 1)", RpcErrorType.INVALID_TRACE_TYPE_PARAMS, e);
}

@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceCallManyParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
@ -67,7 +68,7 @@ public class TraceCallMany extends TraceCall implements JsonRpcMethod {
final Optional<BlockParameter> maybeBlockParameter;
try {
maybeBlockParameter = request.getOptionalParameter(1, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 1)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}

@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
@ -90,7 +91,7 @@ public class TraceFilter extends TraceBlock {
final FilterParameter filterParameter;
try {
filterParameter = requestContext.getRequiredParameter(0, FilterParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid filter parameter (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -58,7 +59,7 @@ public class TraceGet extends AbstractTraceByHash implements JsonRpcMethod {
final Hash transactionHash;
try {
transactionHash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction hash parameter (index 0)",
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,
@ -67,7 +68,7 @@ public class TraceGet extends AbstractTraceByHash implements JsonRpcMethod {
final List<?> traceNumbersAsStrings;
try {
traceNumbersAsStrings = requestContext.getRequiredParameter(1, List.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid trace numbers parameters (index 1)",
RpcErrorType.INVALID_TRACE_NUMBERS_PARAMS,

@ -19,6 +19,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErr
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@ -74,14 +75,14 @@ public class TraceRawTransaction extends AbstractTraceByBlock implements JsonRpc
final String rawTransaction;
try {
rawTransaction = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction parameters (index 0)", RpcErrorType.INVALID_TRANSACTION_PARAMS, e);
}
final TraceTypeParameter traceTypeParameter;
try {
traceTypeParameter = requestContext.getRequiredParameter(1, TraceTypeParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid trace type parameter (index 1)", RpcErrorType.INVALID_TRACE_TYPE_PARAMS, e);
}

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.TraceBlock.ChainUpdater;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
@ -74,7 +75,7 @@ public class TraceReplayBlockTransactions extends AbstractBlockParameterMethod {
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
@ -86,7 +87,7 @@ public class TraceReplayBlockTransactions extends AbstractBlockParameterMethod {
final TraceTypeParameter traceTypeParameter;
try {
traceTypeParameter = request.getRequiredParameter(1, TraceTypeParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid trace type parameter (index 1)", RpcErrorType.INVALID_TRACE_TYPE_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -50,7 +51,7 @@ public class TraceTransaction extends AbstractTraceByHash implements JsonRpcMeth
final Hash transactionHash;
try {
transactionHash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction hash parameter (index 0)",
RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS,

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.PendingTransactionsParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -58,7 +59,7 @@ public class TxPoolBesuPendingTransactions implements JsonRpcMethod {
try {
limit =
requestContext.getOptionalParameter(0, Integer.class).orElse(pendingTransactions.size());
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid transaction limit parameter (index 0)",
RpcErrorType.INVALID_TRANSACTION_LIMIT_PARAMS,
@ -71,7 +72,7 @@ public class TxPoolBesuPendingTransactions implements JsonRpcMethod {
.getOptionalParameter(1, PendingTransactionsParams.class)
.map(PendingTransactionsParams::filters)
.orElse(Collections.emptyList());
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid pending transactions parameter (index 1)",
RpcErrorType.INVALID_PENDING_TRANSACTIONS_PARAMS,

@ -18,6 +18,7 @@ import org.hyperledger.besu.crypto.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -45,7 +46,7 @@ public class Web3Sha3 implements JsonRpcMethod {
final String data;
try {
data = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid data parameter (index 0)", RpcErrorType.INVALID_DATA_PARAMS, e);
}

@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonR
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineForkchoiceUpdatedParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadAttributesParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -84,7 +85,7 @@ public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJso
final EngineForkchoiceUpdatedParameter forkChoice;
try {
forkChoice = requestContext.getRequiredParameter(0, EngineForkchoiceUpdatedParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid engine forkchoice updated parameter (index 0)",
RpcErrorType.INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS,
@ -94,7 +95,7 @@ public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJso
try {
maybePayloadAttributes =
requestContext.getOptionalParameter(1, EnginePayloadAttributesParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid engine payload attributes parameter (index 1)",
RpcErrorType.INVALID_ENGINE_FORKCHOICE_UPDATED_PAYLOAD_ATTRIBUTES,

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -72,7 +73,7 @@ public abstract class AbstractEngineGetPayload extends ExecutionEngineJsonRpcMet
final PayloadIdentifier payloadId;
try {
payloadId = request.getRequiredParameter(0, PayloadIdentifier.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid payload ID parameter (index 0)", RpcErrorType.INVALID_PAYLOAD_ID_PARAMS, e);
}

@ -39,6 +39,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngin
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@ -109,7 +110,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
final EnginePayloadParameter blockParam;
try {
blockParam = requestContext.getRequiredParameter(0, EnginePayloadParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcRequestException(
"Invalid engine payload parameter (index 0)",
RpcErrorType.INVALID_ENGINE_NEW_PAYLOAD_PARAMS,
@ -119,7 +120,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
final Optional<List<String>> maybeVersionedHashParam;
try {
maybeVersionedHashParam = requestContext.getOptionalList(1, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcRequestException(
"Invalid versioned hash parameters (index 1)",
RpcErrorType.INVALID_VERSIONED_HASH_PARAMS,
@ -131,7 +132,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
Optional<String> maybeParentBeaconBlockRootParam;
try {
maybeParentBeaconBlockRootParam = requestContext.getOptionalParameter(2, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcRequestException(
"Invalid parent beacon block root parameters (index 2)",
RpcErrorType.INVALID_PARENT_BEACON_BLOCK_ROOT_PARAMS,

@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -61,8 +62,7 @@ public class EngineExchangeCapabilities extends ExecutionEngineJsonRpcMethod {
() -> {
try {
return requestContext.getRequiredParameter(0, String[].class);
} catch (
Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid remote capabilities parameters (index 0)",
RpcErrorType.INVALID_REMOTE_CAPABILITIES_PARAMS,

@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineExchangeTransitionConfigurationParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@ -72,7 +73,7 @@ public class EngineExchangeTransitionConfiguration extends ExecutionEngineJsonRp
remoteTransitionConfiguration =
requestContext.getRequiredParameter(
0, EngineExchangeTransitionConfigurationParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid engine exchange transition configuration parameters (index 0)",
RpcErrorType.INVALID_ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_PARAMS,

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -64,7 +65,7 @@ public class EngineGetPayloadBodiesByHashV1 extends ExecutionEngineJsonRpcMethod
final Hash[] blockHashes;
try {
blockHashes = request.getRequiredParameter(0, Hash[].class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block hash parameters (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -61,7 +62,7 @@ public class EngineGetPayloadBodiesByRangeV1 extends ExecutionEngineJsonRpcMetho
final long startBlockNumber;
try {
startBlockNumber = request.getRequiredParameter(0, UnsignedLongParameter.class).getValue();
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid start block number parameter (index 0)",
RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS,
@ -70,7 +71,7 @@ public class EngineGetPayloadBodiesByRangeV1 extends ExecutionEngineJsonRpcMetho
final long count;
try {
count = request.getRequiredParameter(1, UnsignedLongParameter.class).getValue();
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block count params (index 1)", RpcErrorType.INVALID_BLOCK_COUNT_PARAMS, e);
}

@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePreparePayloadParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -72,7 +73,7 @@ public class EnginePreparePayloadDebug extends ExecutionEngineJsonRpcMethod {
Optional.empty(),
Optional.empty(),
Optional.empty()));
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid engine prepare payload parameter (index 0)",
RpcErrorType.INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS,

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -49,7 +50,7 @@ public class MinerChangeTargetGasLimit implements JsonRpcMethod {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
RpcErrorType.TARGET_GAS_LIMIT_MODIFICATION_UNSUPPORTED);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid target gas limit parameter (index 0)",
RpcErrorType.INVALID_TARGET_GAS_LIMIT_PARAMS,

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -47,7 +48,7 @@ public class MinerSetCoinbase implements JsonRpcMethod {
} catch (final UnsupportedOperationException ex) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_REQUEST);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -60,12 +61,10 @@ public class MinerSetExtraData implements JsonRpcMethod {
.addArgument(() -> new String(extraData.toArray(), StandardCharsets.UTF_8))
.log();
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
} catch (Exception invalidJsonRpcParameters) { // TODO:replace with "IllegalArgumentException |
// JsonRpcParameter.JsonRpcParameterException"
} catch (IllegalArgumentException | JsonRpcParameterException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
new JsonRpcError(
RpcErrorType.INVALID_EXTRA_DATA_PARAMS, invalidJsonRpcParameters.getMessage()));
new JsonRpcError(RpcErrorType.INVALID_EXTRA_DATA_PARAMS, e.getMessage()));
}
}
}

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -56,7 +57,7 @@ public class MinerSetMinGasPrice implements JsonRpcMethod {
requestContext.getRequest().getId(),
new JsonRpcError(
RpcErrorType.INVALID_MIN_GAS_PRICE_PARAMS, invalidJsonRpcParameters.getMessage()));
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid min gas price parameter (index 0)",
RpcErrorType.INVALID_MIN_GAS_PRICE_PARAMS,

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -51,11 +52,10 @@ public class MinerSetMinPriorityFee implements JsonRpcMethod {
LOG.debug(
"min priority fee per gas changed to {}", minPriorityFeePerGas.toHumanReadableString());
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
} catch (final IllegalArgumentException | JsonRpcParameterException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
new JsonRpcError(
RpcErrorType.INVALID_MIN_PRIORITY_FEE_PARAMS, invalidJsonRpcParameters.getMessage()));
new JsonRpcError(RpcErrorType.INVALID_MIN_PRIORITY_FEE_PARAMS, e.getMessage()));
}
}
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -48,7 +49,7 @@ public class PermAddAccountsToAllowlist implements JsonRpcMethod {
final List<String> accountsList;
try {
accountsList = requestContext.getRequiredParameter(0, List.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid accounts list parameter (index 0)", RpcErrorType.INVALID_ACCOUNT_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -50,7 +51,7 @@ public class PermAddNodesToAllowlist implements JsonRpcMethod {
final StringListParameter enodeListParam;
try {
enodeListParam = requestContext.getRequiredParameter(0, StringListParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid enode list parameter (index 0)", RpcErrorType.INVALID_ENODE_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -48,7 +49,7 @@ public class PermRemoveAccountsFromAllowlist implements JsonRpcMethod {
final List<String> accountsList;
try {
accountsList = requestContext.getRequiredParameter(0, List.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid accounts list parameter (index 0)", RpcErrorType.INVALID_ACCOUNT_PARAMS, e);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -50,7 +51,7 @@ public class PermRemoveNodesFromAllowlist implements JsonRpcMethod {
final StringListParameter enodeListParam;
try {
enodeListParam = requestContext.getRequiredParameter(0, StringListParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid enode list parameter (index 0)", RpcErrorType.INVALID_ENODE_PARAMS, e);
}

@ -14,8 +14,6 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import java.util.List;
import java.util.Optional;
@ -40,13 +38,12 @@ public class JsonRpcParameter {
* @param <T> The type of parameter.
* @return Returns the parameter cast as T if available, otherwise throws exception.
*/
// TODO: update to throw JsonRpcParameterException as a checked exception, forcing callers to
// handle it to supply appropriate context
public <T> T required(final Object[] params, final int index, final Class<T> paramClass) {
public <T> T required(final Object[] params, final int index, final Class<T> paramClass)
throws JsonRpcParameterException {
return optional(params, index, paramClass)
.orElseThrow(
() ->
new InvalidJsonRpcParameters(
new JsonRpcParameterException(
"Missing required json rpc parameter at index " + index));
}
@ -60,11 +57,8 @@ public class JsonRpcParameter {
* @param <T> The type of parameter.
* @return Returns the parameter cast as T if available.
*/
// TODO: update to throw JsonRpcParameterException as a checked exception, forcing callers to
// handle it to supply appropriate context
@SuppressWarnings("unchecked")
public <T> Optional<T> optional(
final Object[] params, final int index, final Class<T> paramClass) {
public <T> Optional<T> optional(final Object[] params, final int index, final Class<T> paramClass)
throws JsonRpcParameterException {
if (params == null || params.length <= index || params[index] == null) {
return Optional.empty();
}
@ -73,14 +67,14 @@ public class JsonRpcParameter {
final Object rawParam = params[index];
if (paramClass.isAssignableFrom(rawParam.getClass())) {
// If we're dealing with a simple type, just cast the value
param = (T) rawParam;
param = paramClass.cast(rawParam);
} else {
// Otherwise, serialize param back to json and then deserialize to the paramClass type
try {
final String json = mapper.writeValueAsString(rawParam);
param = mapper.readValue(json, paramClass);
} catch (final JsonProcessingException e) {
throw new InvalidJsonRpcParameters(
throw new JsonRpcParameterException(
String.format(
"Invalid json rpc parameter at index %d. Supplied value was: '%s' of type: '%s' - expected type: '%s'",
index, rawParam, rawParam.getClass().getName(), paramClass.getName()),
@ -91,10 +85,9 @@ public class JsonRpcParameter {
return Optional.of(param);
}
// TODO: update to throw JsonRpcParameterException as a checked exception, forcing callers to
// handle it to supply appropriate context
public <T> Optional<List<T>> optionalList(
final Object[] params, final int index, final Class<T> listClass) {
final Object[] params, final int index, final Class<T> listClass)
throws JsonRpcParameterException {
if (params == null || params.length <= index || params[index] == null) {
return Optional.empty();
}
@ -105,7 +98,7 @@ public class JsonRpcParameter {
List<T> returnedList = mapper.readValue(listJson, new TypeReference<List<T>>() {});
return Optional.of(returnedList);
} catch (JsonProcessingException e) {
throw new InvalidJsonRpcParameters(
throw new JsonRpcParameterException(
String.format(
"Invalid json rpc parameter at index %d. Supplied value was: '%s' of type: '%s' - expected type: '%s'",
index, rawParam, rawParam.getClass().getName(), listClass.getName()),

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -55,7 +56,7 @@ public class PrivGetFilterChanges implements JsonRpcMethod {
final String privacyGroupId;
try {
privacyGroupId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
@ -64,7 +65,7 @@ public class PrivGetFilterChanges implements JsonRpcMethod {
final String filterId;
try {
filterId = requestContext.getRequiredParameter(1, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid filter ID parameter (index 1)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -55,7 +56,7 @@ public class PrivGetFilterLogs implements JsonRpcMethod {
final String privacyGroupId;
try {
privacyGroupId = request.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid privacy group ID parameter (index 0)",
RpcErrorType.INVALID_PRIVACY_GROUP_PARAMS,
@ -64,7 +65,7 @@ public class PrivGetFilterLogs implements JsonRpcMethod {
final String filterId;
try {
filterId = request.getRequiredParameter(1, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid filter ID parameter (index 1)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save