Skip to content

Commit 9e193ef

Browse files
committed
fix(exception): wrap parameter check exceptions with TronError
1 parent ac6bc5f commit 9e193ef

File tree

2 files changed

+7
-6
lines changed
  • common/src/main/java/org/tron/core/exception
  • framework/src/main/java/org/tron/core/config/args

2 files changed

+7
-6
lines changed

common/src/main/java/org/tron/core/exception/TronError.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public enum ErrCode {
4747
LOG_LOAD(1),
4848
WITNESS_INIT(1),
4949
RATE_LIMITER_INIT(1),
50-
SOLID_NODE_INIT(0);
50+
SOLID_NODE_INIT(0),
51+
PARAMETER_INIT(1);
5152

5253
private final int code;
5354

framework/src/main/java/org/tron/core/config/args/Args.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import static org.tron.core.Constant.MIN_PROPOSAL_EXPIRE_TIME;
1212
import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCE_TIMEOUT_PERCENT;
1313
import static org.tron.core.config.Parameter.ChainConstant.MAX_ACTIVE_WITNESS_NUM;
14+
import static org.tron.core.exception.TronError.ErrCode.PARAMETER_INIT;
1415

1516
import com.beust.jcommander.JCommander;
1617
import com.beust.jcommander.ParameterDescription;
@@ -1276,17 +1277,16 @@ public static void setParam(final Config config) {
12761277

12771278
private static long getProposalExpirationTime(final Config config) {
12781279
if (config.hasPath(Constant.COMMITTEE_PROPOSAL_EXPIRE_TIME)) {
1279-
throw new IllegalArgumentException("It is not allowed to configure "
1280-
+ "commit.proposalExpireTime in config.conf, please set the value in "
1281-
+ "block.proposalExpireTime.");
1280+
throw new TronError("It is not allowed to configure committee.proposalExpireTime in "
1281+
+ "config.conf, please set the value in block.proposalExpireTime.", PARAMETER_INIT);
12821282
}
12831283
if (config.hasPath(Constant.BLOCK_PROPOSAL_EXPIRE_TIME)) {
12841284
long proposalExpireTime = config.getLong(Constant.BLOCK_PROPOSAL_EXPIRE_TIME);
12851285
if (proposalExpireTime <= MIN_PROPOSAL_EXPIRE_TIME
12861286
|| proposalExpireTime >= MAX_PROPOSAL_EXPIRE_TIME) {
1287-
throw new IllegalArgumentException("The value[block.proposalExpireTime] is only allowed to "
1287+
throw new TronError("The value[block.proposalExpireTime] is only allowed to "
12881288
+ "be greater than " + MIN_PROPOSAL_EXPIRE_TIME + " and less than "
1289-
+ MAX_PROPOSAL_EXPIRE_TIME + "!");
1289+
+ MAX_PROPOSAL_EXPIRE_TIME + "!", PARAMETER_INIT);
12901290
}
12911291
return proposalExpireTime;
12921292
} else {

0 commit comments

Comments
 (0)