%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
nl.toolforge.karma.core.manifest.ManifestException |
|
|
1 | /* |
|
2 | Karma core - Core of the Karma application |
|
3 | Copyright (C) 2004 Toolforge <www.toolforge.nl> |
|
4 | ||
5 | This library is free software; you can redistribute it and/or |
|
6 | modify it under the terms of the GNU Lesser General Public |
|
7 | License as published by the Free Software Foundation; either |
|
8 | version 2.1 of the License, or (at your option) any later version. |
|
9 | ||
10 | This library is distributed in the hope that it will be useful, |
|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 | Lesser General Public License for more details. |
|
14 | ||
15 | You should have received a copy of the GNU Lesser General Public |
|
16 | License along with this library; if not, write to the Free Software |
|
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
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 | 60 | private ErrorCode errorCode = null; |
33 | 60 | private Object[] messageArguments = null; |
34 | 44 | |
35 | 44 | 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 | 15 | public static final ErrorCode MANIFEST_NAME_RECURSION = new ErrorCode(EXCEPTION_PREFIX + "00001"); |
40 | /** |
|
41 | 11 | * When a duplicate module-name is encountered in a manifest. |
42 | */ |
|
43 | 15 | public static final ErrorCode DUPLICATE_MODULE = new ErrorCode(EXCEPTION_PREFIX + "00002"); |
44 | /** |
|
45 | 11 | * When the manifest file cannot be found on the users' local harddisk. |
46 | */ |
|
47 | 15 | public static final ErrorCode MANIFEST_FILE_NOT_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00003"); |
48 | /** |
|
49 | 11 | * When a module does not exist in the manifest. |
50 | */ |
|
51 | 15 | public static final ErrorCode MODULE_NOT_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00004"); |
52 | /** |
|
53 | 11 | * When the manifest could not be loaded from disk. |
54 | */ |
|
55 | 15 | public static final ErrorCode MANIFEST_LOAD_ERROR = new ErrorCode(EXCEPTION_PREFIX + "00006"); |
56 | /** |
|
57 | 11 | * If there is no active manifest (none loaded). |
58 | */ |
|
59 | 15 | public static final ErrorCode NO_ACTIVE_MANIFEST = new ErrorCode(EXCEPTION_PREFIX + "00007"); |
60 | /** |
|
61 | 11 | * When the local path to the manifest on disk is invalid. |
62 | */ |
|
63 | 15 | public static final ErrorCode INVALID_LOCAL_PATH = new ErrorCode(EXCEPTION_PREFIX + "00010");; |
64 | /** |
|
65 | 11 | * When the state update for a module failed. |
66 | */ |
|
67 | 15 | public static final ErrorCode STATE_UPDATE_FAILURE = new ErrorCode(EXCEPTION_PREFIX + "00011"); |
68 | /** |
|
69 | 11 | * When a modules' <code>project.xml</code> cannot be found. |
70 | */ |
|
71 | 15 | public static final ErrorCode DEPENDENCY_FILE_NOT_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00013"); |
72 | /** |
|
73 | 11 | * When a module has not yet been checked out for this manifest |
74 | */ |
|
75 | 15 | public static final ErrorCode MODULE_NOT_LOCAL = new ErrorCode(EXCEPTION_PREFIX + "00014"); |
76 | /** |
|
77 | 11 | * When the <code>dependencies.xml</code> file could not be loaded correctly. |
78 | */ |
|
79 | 15 | public static final ErrorCode DEPENDENCY_FILE_LOAD_ERROR = new ErrorCode(EXCEPTION_PREFIX + "00015"); |
80 | ||
81 | 11 | /** |
82 | * When the manifest is a {@link ReleaseManifest} all modules should have a <code>version</code> attribute. |
|
83 | */ |
|
84 | 15 | public static final ErrorCode MODULE_WITHOUT_VERSION = new ErrorCode(EXCEPTION_PREFIX + "00016"); |
85 | ||
86 | 26 | public static final ErrorCode DUPLICATE_MANIFEST_FILE = new ErrorCode(EXCEPTION_PREFIX + "00018"); |
87 | ||
88 | 11 | public ManifestException(ErrorCode errorCode) { |
89 | 0 | this(errorCode, null); |
90 | 0 | } |
91 | ||
92 | public ManifestException(ErrorCode errorCode, Object[] messageArguments) { |
|
93 | 60 | super(); |
94 | 60 | this.errorCode = errorCode; |
95 | 104 | this.messageArguments = messageArguments; |
96 | 104 | } |
97 | 44 | |
98 | 44 | public ManifestException(Throwable t, ErrorCode errorCode, Object[] messageArguments) { |
99 | 0 | super(t); |
100 | 0 | this.errorCode = errorCode; |
101 | 0 | this.messageArguments = messageArguments; |
102 | 0 | } |
103 | ||
104 | public String getMessage() { |
|
105 | 30 | if (messageArguments != null && messageArguments.length > 0) { |
106 | 30 | errorCode.setMessageArguments(messageArguments); |
107 | 22 | } |
108 | 52 | return errorCode.getErrorMessage(); |
109 | } |
|
110 | 22 | |
111 | /** |
|
112 | * Gets the exceptions' {@link nl.toolforge.karma.core.ErrorCode}. |
|
113 | * @return |
|
114 | */ |
|
115 | public final ErrorCode getErrorCode() { |
|
116 | 60 | return errorCode; |
117 | } |
|
118 | 44 | |
119 | public final Object[] getMessageArguments() { |
|
120 | 30 | return messageArguments; |
121 | } |
|
122 | 22 | |
123 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |