%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
nl.toolforge.karma.core.location.LocationException |
|
|
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.location; |
|
20 | ||
21 | import nl.toolforge.karma.core.ErrorCode; |
|
22 | ||
23 | /** |
|
24 | * <p>Exceptions relating to <code>Location</code>s. As with all other <code>KarmaExceptions</code>, exceptions can |
|
25 | * only be thrown with a certain <code>ErrorCode</code>. |
|
26 | * |
|
27 | * @author D.A. Smedes |
|
28 | * @version $Id: LocationException.java,v 1.23 2004/11/02 23:57:06 asmedes Exp $ |
|
29 | */ |
|
30 | public final class LocationException extends Exception { |
|
31 | ||
32 | 15 | private ErrorCode errorCode = null; |
33 | 15 | private Object[] messageArguments = null; |
34 | 701 | |
35 | 701 | /** |
36 | * This is the prefix that is shown when displaying the error. |
|
37 | */ |
|
38 | public static final String EXCEPTION_PREFIX = "LOC-"; |
|
39 | ||
40 | /** |
|
41 | * Location descriptor does not exist. This happens when a module's 'location'-attribute cannot be found by the |
|
42 | * <code>LocationFactory</code>, which contains references to all <code>Location</code> objects mapped in |
|
43 | * <code>locations.xml</code>. |
|
44 | */ |
|
45 | 15 | public static final ErrorCode LOCATION_NOT_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00005"); |
46 | /** |
|
47 | 121 | * No location files were found. Karma filters all <code>*.xml</code>-files from |
48 | * {@link nl.toolforge.karma.core.boot.WorkingContext#getLocationStore()}. |
|
49 | */ |
|
50 | 15 | public static final ErrorCode NO_LOCATION_DATA_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00006"); |
51 | ||
52 | 121 | /** Missing location property */ |
53 | 15 | public static final ErrorCode MISSING_LOCATION_PROPERTY = new ErrorCode(EXCEPTION_PREFIX + "00010"); |
54 | /** |
|
55 | 121 | * The manifest-store is configured based on properties in <code>karma.properties</code>. This error code is |
56 | * created when the <code>Location</code> for the manifest-store could not be created succesfully. |
|
57 | */ |
|
58 | 15 | public static final ErrorCode INVALID_MANIFEST_STORE_LOCATION = new ErrorCode(EXCEPTION_PREFIX + "00011"); |
59 | /** |
|
60 | 121 | * The location-store is configured based on properties in <code>karma.properties</code>. This error code is |
61 | * created when the <code>Location</code> for the location-store could not be created succesfully. |
|
62 | */ |
|
63 | 15 | public static final ErrorCode INVALID_LOCATION_STORE_LOCATION = new ErrorCode(EXCEPTION_PREFIX + "00012"); |
64 | ||
65 | 136 | public static final ErrorCode DUPLICATE_LOCATION_KEY = new ErrorCode(EXCEPTION_PREFIX + "00013"); |
66 | ||
67 | 121 | /** |
68 | * An xml file with locations could not be loaded. |
|
69 | */ |
|
70 | 15 | public static final ErrorCode LOCATION_LOAD_ERROR = new ErrorCode(EXCEPTION_PREFIX + "00017"); |
71 | ||
72 | 121 | /** |
73 | * A <code>LOCATION_MISMATCH</code> occurs when a module is locally available and an update is requested from |
|
74 | * another location. A version control system generally gives an error for this. |
|
75 | */ |
|
76 | 15 | public static final ErrorCode LOCATION_MISMATCH = new ErrorCode(EXCEPTION_PREFIX + "00018"); |
77 | ||
78 | 121 | /** |
79 | * A connection to the location could not be made. |
|
80 | */ |
|
81 | 15 | public static final ErrorCode CONNECTION_EXCEPTION = new ErrorCode(EXCEPTION_PREFIX + "00019"); |
82 | ||
83 | 121 | |
84 | /** The location was configured incorrectly. */ |
|
85 | // public static final ErrorCode LOCATION_CONFIGURATION_ERROR = new ErrorCode(EXCEPTION_PREFIX + "00007"); |
|
86 | ||
87 | // Location configuration error codes. Used when the locations xml are misconfigured. |
|
88 | // |
|
89 | ||
90 | 15 | public static final ErrorCode INVALID_LOCATION_TYPE = new ErrorCode(EXCEPTION_PREFIX + "00020"); |
91 | ||
92 | 136 | public static final ErrorCode INVALID_ELEMENT_VALUE = new ErrorCode(EXCEPTION_PREFIX + "00021"); |
93 | ||
94 | 121 | |
95 | public LocationException(ErrorCode errorCode) { |
|
96 | 0 | this(errorCode, null); |
97 | 0 | } |
98 | 690 | |
99 | 690 | public LocationException(Throwable t, ErrorCode errorCode) { |
100 | 0 | this(t, errorCode, null); |
101 | 0 | } |
102 | ||
103 | public LocationException(ErrorCode errorCode, Object[] messageArguments) { |
|
104 | 15 | super(); |
105 | 15 | this.errorCode = errorCode; |
106 | 716 | this.messageArguments = messageArguments; |
107 | 716 | } |
108 | 701 | |
109 | 701 | public LocationException(Throwable t, ErrorCode errorCode, Object[] messageArguments) { |
110 | 0 | super(t); |
111 | 0 | this.errorCode = errorCode; |
112 | 0 | this.messageArguments = messageArguments; |
113 | 0 | } |
114 | ||
115 | /** |
|
116 | * Helper method to get the localized error message based on the {@link nl.toolforge.karma.core.ErrorCode}. |
|
117 | */ |
|
118 | // public final String getErrorMessage() { |
|
119 | // if (messageArguments != null && messageArguments.length > 0) { |
|
120 | // errorCode.setMessageArguments(messageArguments); |
|
121 | // } |
|
122 | // return errorCode.getErrorMessage(); |
|
123 | // } |
|
124 | ||
125 | public String getMessage() { |
|
126 | 0 | if (messageArguments != null && messageArguments.length > 0) { |
127 | 0 | errorCode.setMessageArguments(messageArguments); |
128 | } |
|
129 | 0 | return errorCode.getErrorMessage(); |
130 | } |
|
131 | ||
132 | /** |
|
133 | * Gets the exceptions' {@link nl.toolforge.karma.core.ErrorCode}. |
|
134 | */ |
|
135 | public final ErrorCode getErrorCode() { |
|
136 | 0 | return errorCode; |
137 | } |
|
138 | ||
139 | /** |
|
140 | * Retrieves the message arguments for this exception. |
|
141 | */ |
|
142 | public final Object[] getMessageArguments() { |
|
143 | 0 | return messageArguments; |
144 | } |
|
145 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |