1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package nl.toolforge.karma.core.vc;
20
21 import nl.toolforge.karma.core.ErrorCode;
22
23 /***
24 * Root exception for stuff relating to version control system functionality.
25 *
26 * @author D.A. Smedes
27 * @version $Id: VersionControlException.java,v 1.19 2004/11/02 22:26:44 asmedes Exp $
28 */
29 public abstract class VersionControlException extends Exception {
30
31 private ErrorCode errorCode = null;
32 private Object[] messageArguments = null;
33
34 public static String EXCEPTION_PREFIX = "VER-";
35 /*** Version already exists for this module. */
36 public static final ErrorCode DUPLICATE_VERSION = new ErrorCode(EXCEPTION_PREFIX + "00001");
37 /*** The requested module does not exist in the repository */
38 public static final ErrorCode MODULE_NOT_IN_REPOSITORY = new ErrorCode(EXCEPTION_PREFIX + "00002");
39 /*** A <code>Location</code> instance was required, but missing. */
40 public static final ErrorCode MISSING_LOCATION = new ErrorCode(EXCEPTION_PREFIX + "00003");;
41
42
43 public VersionControlException(ErrorCode errorCode) {
44 this(errorCode, null);
45 }
46
47 public VersionControlException(Throwable t, ErrorCode errorCode) {
48 this(t, errorCode, null);
49 }
50
51 public VersionControlException(ErrorCode errorCode, Object[] messageArguments) {
52 super();
53 this.errorCode = errorCode;
54 this.messageArguments = messageArguments;
55 }
56
57 public VersionControlException(Throwable t, ErrorCode errorCode, Object[] messageArguments) {
58 super(t);
59 this.errorCode = errorCode;
60 this.messageArguments = messageArguments;
61 }
62
63 public String getMessage() {
64 if (messageArguments != null && messageArguments.length > 0) {
65 errorCode.setMessageArguments(messageArguments);
66 }
67 return getErrorCode().getErrorMessage();
68 }
69
70 /***
71 * Gets the exceptions' {@link nl.toolforge.karma.core.ErrorCode}.
72 * @return
73 */
74 public final ErrorCode getErrorCode() {
75 return errorCode;
76 }
77
78 public final Object[] getMessageArguments() {
79 return messageArguments;
80 }
81 }