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.util;
20
21 import nl.toolforge.karma.core.ErrorCode;
22
23 /***
24 * Thrown when
25 *
26 * @author D.A. Smedes
27 * @version $Id: DependencyException.java,v 1.10 2004/11/02 23:57:06 asmedes Exp $
28 */
29 public class DependencyException extends Exception {
30
31 private ErrorCode errorCode = null;
32 private Object[] messageArguments = null;
33
34 public static final String EXCEPTION_PREFIX = "DEP-";
35
36 /***
37 * A dependency is configured, but cannot be found on a developers machine.
38 */
39 public static final ErrorCode DEPENDENCY_NOT_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00001");
40
41 /*** A dependency on a module has been defined, but the module is not in the manifest */
42 public static final ErrorCode MODULE_NOT_IN_MANIFEST = new ErrorCode(EXCEPTION_PREFIX + "00004");
43
44 public static final ErrorCode DUPLICATE_ARTIFACT_VERSION = new ErrorCode(EXCEPTION_PREFIX + "00002");
45 public static final ErrorCode EAR_DEPENDENCY_NOT_DEFINED = new ErrorCode(EXCEPTION_PREFIX + "00003");
46 public static final ErrorCode EAR_DEPENDENCY_NOT_FOUND = new ErrorCode(EXCEPTION_PREFIX + "00005");
47
48 public DependencyException(ErrorCode errorCode) {
49 this(errorCode, null);
50 }
51
52 public DependencyException(ErrorCode errorCode, Object[] messageArguments) {
53 super();
54 this.errorCode = errorCode;
55 this.messageArguments = messageArguments;
56 }
57
58 public DependencyException(Throwable t, ErrorCode errorCode, Object[] messageArguments) {
59 super(t);
60 this.errorCode = errorCode;
61 this.messageArguments = messageArguments;
62 }
63
64 public String getMessage() {
65 if (messageArguments != null && messageArguments.length > 0) {
66 errorCode.setMessageArguments(messageArguments);
67 }
68 return errorCode.getErrorMessage();
69 }
70
71 /***
72 * Gets the exceptions' {@link nl.toolforge.karma.core.ErrorCode}.
73 * @return
74 */
75 public final ErrorCode getErrorCode() {
76 return errorCode;
77 }
78
79 public final Object[] getMessageArguments() {
80 return messageArguments;
81 }
82
83
84
85 }