| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package nl.toolforge.karma.core.cmd; |
| 20 |
|
|
| 21 |
|
import nl.toolforge.karma.core.ErrorCode; |
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
public class CommandException extends Exception { |
| 30 |
|
|
| 31 |
78 |
private ErrorCode errorCode = null; |
| 32 |
78 |
private Object[] messageArguments = null; |
| 33 |
|
|
| 34 |
|
public static final String EXCEPTION_PREFIX = "CMD-"; |
| 35 |
|
|
| 36 |
|
|
| 37 |
26 |
public static final ErrorCode TEST_CODE = new ErrorCode(EXCEPTION_PREFIX + "00000"); |
| 38 |
|
|
| 39 |
26 |
public static final ErrorCode NO_IMPLEMENTING_CLASS = new ErrorCode(EXCEPTION_PREFIX + "00001"); |
| 40 |
|
|
| 41 |
26 |
public static final ErrorCode UNKNOWN_COMMAND = new ErrorCode(EXCEPTION_PREFIX + "00029"); |
| 42 |
|
|
| 43 |
26 |
public static final ErrorCode INVALID_COMMAND = new ErrorCode(EXCEPTION_PREFIX + "00030"); |
| 44 |
|
|
| 45 |
26 |
public static ErrorCode MISSING_OPTION = new ErrorCode(EXCEPTION_PREFIX + "00031"); |
| 46 |
|
|
| 47 |
26 |
public static ErrorCode MISSING_ARGUMENT = new ErrorCode(EXCEPTION_PREFIX + "00032"); |
| 48 |
|
|
| 49 |
26 |
public static ErrorCode INVALID_ARGUMENT = new ErrorCode(EXCEPTION_PREFIX + "00033"); |
| 50 |
|
|
| 51 |
26 |
public static final ErrorCode INVALID_OPTION = new ErrorCode(EXCEPTION_PREFIX + "00034"); |
| 52 |
|
|
| 53 |
26 |
public static final ErrorCode NO_OPTIONS_REQUIRED = new ErrorCode(EXCEPTION_PREFIX + "00035");; |
| 54 |
|
|
| 55 |
26 |
public static final ErrorCode BUILD_FAILED = new ErrorCode(EXCEPTION_PREFIX + "00040"); |
| 56 |
|
|
| 57 |
26 |
public static final ErrorCode BUILD_FAILED_TOO_MANY_MISSING_DEPENDENCIES = new ErrorCode(EXCEPTION_PREFIX + "00046"); |
| 58 |
|
|
| 59 |
26 |
public static final ErrorCode TEST_FAILED = new ErrorCode(EXCEPTION_PREFIX + "00050"); |
| 60 |
|
|
| 61 |
26 |
public static final ErrorCode TEST_REPORT_FAILED = new ErrorCode(EXCEPTION_PREFIX + "00052"); |
| 62 |
|
|
| 63 |
26 |
public static final ErrorCode CLEAN_MODULE_FAILED = new ErrorCode(EXCEPTION_PREFIX + "00060"); |
| 64 |
|
|
| 65 |
26 |
public static final ErrorCode CLEAN_ALL_FAILED = new ErrorCode(EXCEPTION_PREFIX + "00063"); |
| 66 |
|
|
| 67 |
26 |
public static final ErrorCode PACKAGE_FAILED = new ErrorCode(EXCEPTION_PREFIX + "00070"); |
| 68 |
|
|
| 69 |
26 |
public static final ErrorCode PACKAGE_FAILED_NOTHING_TO_PACKAGE = new ErrorCode(EXCEPTION_PREFIX + "00074"); |
| 70 |
|
|
| 71 |
26 |
public static final ErrorCode PACKAGE_FAILED_NO_APPLICATION_XML = new ErrorCode(EXCEPTION_PREFIX + "00071"); |
| 72 |
|
|
| 73 |
26 |
public static final ErrorCode PACKAGE_FAILED_INVALID_APPLICATION_XML = new ErrorCode(EXCEPTION_PREFIX + "00072"); |
| 74 |
|
|
| 75 |
26 |
public static final ErrorCode PACKAGE_FAILED_WRONG_MODULE_TYPE = new ErrorCode(EXCEPTION_PREFIX + "00073"); |
| 76 |
|
|
| 77 |
26 |
public static final ErrorCode START_WORK_NOT_ALLOWED_ON_STATIC_MODULE = new ErrorCode(EXCEPTION_PREFIX + "00041"); |
| 78 |
|
|
| 79 |
26 |
public static final ErrorCode MODULE_TYPE_MUST_BE_BASEMODULE = new ErrorCode(EXCEPTION_PREFIX + "00042"); |
| 80 |
|
|
| 81 |
15 |
public static final ErrorCode PROMOTE_ONLY_ALLOWED_ON_WORKING_MODULE = new ErrorCode(EXCEPTION_PREFIX + "00043"); |
| 82 |
|
|
| 83 |
10 |
public static final ErrorCode PROMOTE_WITH_INCREASE_MAJOR_VERSION_NOT_ALLOWED_ON_RELEASE_MANIFEST = new ErrorCode(EXCEPTION_PREFIX + "00075"); |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
11 |
|
| 90 |
|
|
| 91 |
11 |
|
| 92 |
5 |
|
| 93 |
11 |
|
| 94 |
15 |
public static final ErrorCode DEPENDENCY_DOES_NOT_EXIST = new ErrorCode(EXCEPTION_PREFIX + "00044"); |
| 95 |
11 |
|
| 96 |
15 |
public static final ErrorCode DEPENDENCY_FILE_INVALID = new ErrorCode(EXCEPTION_PREFIX + "00047"); |
| 97 |
11 |
|
| 98 |
15 |
public static final ErrorCode NO_SRC_DIR = new ErrorCode(EXCEPTION_PREFIX + "00045"); |
| 99 |
11 |
|
| 100 |
15 |
public static final ErrorCode NO_TEST_DIR = new ErrorCode(EXCEPTION_PREFIX + "00051"); |
| 101 |
11 |
|
| 102 |
15 |
public static final ErrorCode UNCOMMITTED_NEW_FILES = new ErrorCode(EXCEPTION_PREFIX + "00055"); |
| 103 |
11 |
|
| 104 |
15 |
public static final ErrorCode UNCOMMITTED_CHANGED_FILES = new ErrorCode(EXCEPTION_PREFIX + "00056"); |
| 105 |
11 |
|
| 106 |
15 |
public static final ErrorCode UNCOMMITTED_REMOVED_FILES = new ErrorCode(EXCEPTION_PREFIX + "00057"); |
| 107 |
11 |
|
| 108 |
15 |
public static final ErrorCode NO_MODULE_BUILD_DIR = new ErrorCode(EXCEPTION_PREFIX + "00061"); |
| 109 |
11 |
|
| 110 |
15 |
public static final ErrorCode NO_BUILD_DIR = new ErrorCode(EXCEPTION_PREFIX + "00062"); |
| 111 |
11 |
|
| 112 |
15 |
public static final ErrorCode MODULE_VERSION_ERROR = new ErrorCode(EXCEPTION_PREFIX + "00064"); |
| 113 |
11 |
|
| 114 |
15 |
public static final ErrorCode TEST_WARNING = new ErrorCode(EXCEPTION_PREFIX + "00100"); |
| 115 |
11 |
|
| 116 |
15 |
public static final ErrorCode BUILD_WARNING = new ErrorCode(EXCEPTION_PREFIX + "00101"); |
| 117 |
11 |
|
| 118 |
15 |
public static final ErrorCode INVALID_STATE_MODULE_NOT_WORKING = new ErrorCode(EXCEPTION_PREFIX + "00102"); |
| 119 |
11 |
|
| 120 |
15 |
public static final ErrorCode MODULE_NOT_LOCAL = new ErrorCode(EXCEPTION_PREFIX + "00103"); |
| 121 |
|
|
| 122 |
26 |
public static final ErrorCode INVALID_LOCATION_TYPE = new ErrorCode(EXCEPTION_PREFIX + "00104"); |
| 123 |
11 |
|
| 124 |
10 |
public static final ErrorCode CANNOT_INITIALIZE_WORKING_CONTEXT = new ErrorCode(EXCEPTION_PREFIX + "00105"); |
| 125 |
5 |
|
| 126 |
12 |
public static final ErrorCode MODULE_CANNOT_BE_WORKING_FOR_RELEASE_MANIFEST = new ErrorCode(EXCEPTION_PREFIX + "00106"); |
| 127 |
3 |
|
| 128 |
8 |
public static final ErrorCode INVALID_WORKING_CONTEXT_CONFIGURATION = new ErrorCode(EXCEPTION_PREFIX + "00107"); |
| 129 |
2 |
|
| 130 |
35 |
public CommandException(ErrorCode errorCode) { |
| 131 |
38 |
this(errorCode, null); |
| 132 |
38 |
} |
| 133 |
48 |
|
| 134 |
15 |
public CommandException(Throwable t, ErrorCode errorCode) { |
| 135 |
24 |
this(t, errorCode, null); |
| 136 |
24 |
} |
| 137 |
15 |
|
| 138 |
15 |
public CommandException(ErrorCode errorCode, Object[] messageArguments) { |
| 139 |
21 |
super(); |
| 140 |
21 |
this.errorCode = errorCode; |
| 141 |
15 |
this.messageArguments = messageArguments; |
| 142 |
48 |
} |
| 143 |
22 |
|
| 144 |
|
public CommandException(Throwable t, ErrorCode errorCode, Object[] messageArguments) { |
| 145 |
48 |
super(t); |
| 146 |
10 |
this.errorCode = errorCode; |
| 147 |
9 |
this.messageArguments = messageArguments; |
| 148 |
21 |
} |
| 149 |
6 |
|
| 150 |
13 |
public String getMessage() { |
| 151 |
15 |
if (messageArguments != null && messageArguments.length > 0) { |
| 152 |
16 |
errorCode.setMessageArguments(messageArguments); |
| 153 |
33 |
} |
| 154 |
15 |
return getErrorCode().getErrorMessage(); |
| 155 |
|
} |
| 156 |
15 |
|
| 157 |
|
|
| 158 |
9 |
|
| 159 |
|
|
| 160 |
6 |
|
| 161 |
|
public final ErrorCode getErrorCode() { |
| 162 |
15 |
return errorCode; |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
public final Object[] getMessageArguments() { |
| 166 |
0 |
return messageArguments; |
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
} |