1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shardingsphere.infra.algorithm.core.exception;
19
20 import com.google.common.base.Preconditions;
21 import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.SQLState;
22 import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.MetaDataSQLException;
23
24
25
26
27 public abstract class AlgorithmDefinitionException extends MetaDataSQLException {
28
29 private static final long serialVersionUID = -8947223495845000542L;
30
31 private static final int ALGORITHM_CODE = 4;
32
33 protected AlgorithmDefinitionException(final SQLState sqlState, final int errorCode, final String reason, final Object... messageArgs) {
34 super(sqlState, getErrorCode(errorCode), reason, messageArgs);
35 }
36
37 private static int getErrorCode(final int errorCode) {
38 Preconditions.checkArgument(errorCode >= 0 && errorCode < 100, "The value range of error code should be [0, 100).");
39 return ALGORITHM_CODE * 100 + errorCode;
40 }
41 }