01: /*
02: * ====================================================================
03: * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved.
04: *
05: * This software is licensed as described in the file COPYING, which
06: * you should have received as part of this distribution. The terms
07: * are also available at http://svnkit.com/license.html
08: * If newer versions of this license are posted there, you may use a
09: * newer version instead, at your option.
10: * ====================================================================
11: */
12:
13: package org.tmatesoft.svn.core;
14:
15: /**
16: * A main exception class that is used in the SVNKit library. All other
17: * SVNKit exception classes extend this one. Detailed information
18: * on the error (description, error code) is encapsulated inside an error
19: * message that is held by an <b>SVNException</b>.
20: *
21: * @version 1.1.1
22: * @author TMate Software Ltd.
23: */
24: public class SVNException extends Exception {
25:
26: private SVNErrorMessage myErrorMessage;
27:
28: /**
29: * Creates an exception given an error message.
30: *
31: * @param errorMessage an error message
32: */
33: public SVNException(SVNErrorMessage errorMessage) {
34: this (errorMessage, null);
35: }
36:
37: /**
38: * Creates an exception given an error message and the cause exception.
39: *
40: * @param errorMessage an error message
41: * @param cause the real cause of the error
42: */
43: public SVNException(SVNErrorMessage errorMessage, Throwable cause) {
44: super (cause);
45: if (cause instanceof SVNException) {
46: SVNErrorMessage childMessages = ((SVNException) cause)
47: .getErrorMessage();
48: SVNErrorMessage parent = errorMessage;
49: while (parent.hasChildErrorMessage()) {
50: parent = parent.getChildErrorMessage();
51: }
52: if (parent != childMessages) {
53: parent.setChildErrorMessage(childMessages);
54: }
55: }
56: myErrorMessage = errorMessage;
57: }
58:
59: /**
60: * Returns an error message provided to this exception object.
61: *
62: * @return an error message that contains details on the error
63: */
64: public SVNErrorMessage getErrorMessage() {
65: return myErrorMessage;
66: }
67:
68: /**
69: * Returns the informational message describing the cause
70: * of this exception.
71: *
72: * @return an informational message
73: */
74: public String getMessage() {
75: SVNErrorMessage error = getErrorMessage();
76: if (error != null) {
77: return error.getFullMessage();
78: }
79: return super.getMessage();
80: }
81: }
|