From 9e193efe50dd3865e44b16a0c2015a3df0849743 Mon Sep 17 00:00:00 2001 From: liuxincheng Date: Mon, 22 Sep 2025 17:56:18 +0800 Subject: [PATCH] fix(exception): wrap parameter check exceptions with TronError --- .../main/java/org/tron/core/exception/TronError.java | 3 ++- .../src/main/java/org/tron/core/config/args/Args.java | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/org/tron/core/exception/TronError.java b/common/src/main/java/org/tron/core/exception/TronError.java index 9d11d249476..263414550c2 100644 --- a/common/src/main/java/org/tron/core/exception/TronError.java +++ b/common/src/main/java/org/tron/core/exception/TronError.java @@ -47,7 +47,8 @@ public enum ErrCode { LOG_LOAD(1), WITNESS_INIT(1), RATE_LIMITER_INIT(1), - SOLID_NODE_INIT(0); + SOLID_NODE_INIT(0), + PARAMETER_INIT(1); private final int code; diff --git a/framework/src/main/java/org/tron/core/config/args/Args.java b/framework/src/main/java/org/tron/core/config/args/Args.java index a716997419e..4a4b6eb8150 100644 --- a/framework/src/main/java/org/tron/core/config/args/Args.java +++ b/framework/src/main/java/org/tron/core/config/args/Args.java @@ -11,6 +11,7 @@ import static org.tron.core.Constant.MIN_PROPOSAL_EXPIRE_TIME; import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCE_TIMEOUT_PERCENT; import static org.tron.core.config.Parameter.ChainConstant.MAX_ACTIVE_WITNESS_NUM; +import static org.tron.core.exception.TronError.ErrCode.PARAMETER_INIT; import com.beust.jcommander.JCommander; import com.beust.jcommander.ParameterDescription; @@ -1276,17 +1277,16 @@ public static void setParam(final Config config) { private static long getProposalExpirationTime(final Config config) { if (config.hasPath(Constant.COMMITTEE_PROPOSAL_EXPIRE_TIME)) { - throw new IllegalArgumentException("It is not allowed to configure " - + "commit.proposalExpireTime in config.conf, please set the value in " - + "block.proposalExpireTime."); + throw new TronError("It is not allowed to configure committee.proposalExpireTime in " + + "config.conf, please set the value in block.proposalExpireTime.", PARAMETER_INIT); } if (config.hasPath(Constant.BLOCK_PROPOSAL_EXPIRE_TIME)) { long proposalExpireTime = config.getLong(Constant.BLOCK_PROPOSAL_EXPIRE_TIME); if (proposalExpireTime <= MIN_PROPOSAL_EXPIRE_TIME || proposalExpireTime >= MAX_PROPOSAL_EXPIRE_TIME) { - throw new IllegalArgumentException("The value[block.proposalExpireTime] is only allowed to " + throw new TronError("The value[block.proposalExpireTime] is only allowed to " + "be greater than " + MIN_PROPOSAL_EXPIRE_TIME + " and less than " - + MAX_PROPOSAL_EXPIRE_TIME + "!"); + + MAX_PROPOSAL_EXPIRE_TIME + "!", PARAMETER_INIT); } return proposalExpireTime; } else {