1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package nl.toolforge.karma.core.manifest;
20
21 import nl.toolforge.karma.core.ErrorCode;
22
23
24 /***
25 * Exception thrown by the AbstractManifest Domain.
26 *
27 * @author D.A. Smedes
28 * @version $Id: ManifestException.java,v 1.21 2004/11/02 23:57:06 asmedes Exp $
29 */
30 public class ManifestException extends Exception {
31
32 private ErrorCode errorCode = null;
33 private Object[] messageArguments = null;
34
35 public static final String EXCEPTION_PREFIX = "MAN-";
36 /***
37 * When a manifest is included with the same name as an already loaded manifest.
38 */
39 public static final ErrorCode MANIFEST_NAME_RECURSION = new ErrorCode(EXCEPTION_PREFIX + "00001");
40 /***
41 * When a duplicate module-name is encountered in a manifest.
42 */
43 public static final ErrorCode DUPLICATE_MODULE = new ErrorCode(EXCEPTION_PREFIX + "00002");
44 /***
45 * When the manifest file cannot be found on the users' local harddisk.
46 */
47 public static final ErrorCode MANIFEST_FILE_NOT_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00003");
48 /***
49 * When a module does not exist in the manifest.
50 */
51 public static final ErrorCode MODULE_NOT_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00004");
52 /***
53 * When the manifest could not be loaded from disk.
54 */
55 public static final ErrorCode MANIFEST_LOAD_ERROR = new ErrorCode(EXCEPTION_PREFIX + "00006");
56 /***
57 * If there is no active manifest (none loaded).
58 */
59 public static final ErrorCode NO_ACTIVE_MANIFEST = new ErrorCode(EXCEPTION_PREFIX + "00007");
60 /***
61 * When the local path to the manifest on disk is invalid.
62 */
63 public static final ErrorCode INVALID_LOCAL_PATH = new ErrorCode(EXCEPTION_PREFIX + "00010");;
64 /***
65 * When the state update for a module failed.
66 */
67 public static final ErrorCode STATE_UPDATE_FAILURE = new ErrorCode(EXCEPTION_PREFIX + "00011");
68 /***
69 * When a modules' <code>project.xml</code> cannot be found.
70 */
71 public static final ErrorCode DEPENDENCY_FILE_NOT_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00013");
72 /***
73 * When a module has not yet been checked out for this manifest
74 */
75 public static final ErrorCode MODULE_NOT_LOCAL = new ErrorCode(EXCEPTION_PREFIX + "00014");
76 /***
77 * When the <code>dependencies.xml</code> file could not be loaded correctly.
78 */
79 public static final ErrorCode DEPENDENCY_FILE_LOAD_ERROR = new ErrorCode(EXCEPTION_PREFIX + "00015");
80
81 /***
82 * When the manifest is a {@link ReleaseManifest} all modules should have a <code>version</code> attribute.
83 */
84 public static final ErrorCode MODULE_WITHOUT_VERSION = new ErrorCode(EXCEPTION_PREFIX + "00016");
85
86 public static final ErrorCode DUPLICATE_MANIFEST_FILE = new ErrorCode(EXCEPTION_PREFIX + "00018");
87
88 public ManifestException(ErrorCode errorCode) {
89 this(errorCode, null);
90 }
91
92 public ManifestException(ErrorCode errorCode, Object[] messageArguments) {
93 super();
94 this.errorCode = errorCode;
95 this.messageArguments = messageArguments;
96 }
97
98 public ManifestException(Throwable t, ErrorCode errorCode, Object[] messageArguments) {
99 super(t);
100 this.errorCode = errorCode;
101 this.messageArguments = messageArguments;
102 }
103
104 public String getMessage() {
105 if (messageArguments != null && messageArguments.length > 0) {
106 errorCode.setMessageArguments(messageArguments);
107 }
108 return errorCode.getErrorMessage();
109 }
110
111 /***
112 * Gets the exceptions' {@link nl.toolforge.karma.core.ErrorCode}.
113 * @return
114 */
115 public final ErrorCode getErrorCode() {
116 return errorCode;
117 }
118
119 public final Object[] getMessageArguments() {
120 return messageArguments;
121 }
122
123 }