Skip to content

Commit b5a7fcd

Browse files
authored
fix(exception): wrap parameter check exceptions with TronError (#6454)
1 parent b9753ce commit b5a7fcd

File tree

2 files changed

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

2 files changed

+8
-7
lines changed

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

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

5354
private final int code;
5455

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
@@ -12,6 +12,7 @@
1212
import static org.tron.core.Constant.MIN_PROPOSAL_EXPIRE_TIME;
1313
import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCE_TIMEOUT_PERCENT;
1414
import static org.tron.core.config.Parameter.ChainConstant.MAX_ACTIVE_WITNESS_NUM;
15+
import static org.tron.core.exception.TronError.ErrCode.PARAMETER_INIT;
1516

1617
import com.beust.jcommander.JCommander;
1718
import com.beust.jcommander.ParameterDescription;
@@ -1288,17 +1289,16 @@ public static void setParam(final Config config) {
12881289

12891290
private static long getProposalExpirationTime(final Config config) {
12901291
if (config.hasPath(Constant.COMMITTEE_PROPOSAL_EXPIRE_TIME)) {
1291-
throw new IllegalArgumentException("It is not allowed to configure "
1292-
+ "commit.proposalExpireTime in config.conf, please set the value in "
1293-
+ "block.proposalExpireTime.");
1292+
throw new TronError("It is not allowed to configure committee.proposalExpireTime in "
1293+
+ "config.conf, please set the value in block.proposalExpireTime.", PARAMETER_INIT);
12941294
}
12951295
if (config.hasPath(Constant.BLOCK_PROPOSAL_EXPIRE_TIME)) {
12961296
long proposalExpireTime = config.getLong(Constant.BLOCK_PROPOSAL_EXPIRE_TIME);
12971297
if (proposalExpireTime <= MIN_PROPOSAL_EXPIRE_TIME
12981298
|| proposalExpireTime >= MAX_PROPOSAL_EXPIRE_TIME) {
1299-
throw new IllegalArgumentException("The value[block.proposalExpireTime] is only allowed to "
1299+
throw new TronError("The value[block.proposalExpireTime] is only allowed to "
13001300
+ "be greater than " + MIN_PROPOSAL_EXPIRE_TIME + " and less than "
1301-
+ MAX_PROPOSAL_EXPIRE_TIME + "!");
1301+
+ MAX_PROPOSAL_EXPIRE_TIME + "!", PARAMETER_INIT);
13021302
}
13031303
return proposalExpireTime;
13041304
} else {

0 commit comments

Comments
 (0)