01: /*
02: * Copyright (C) 2007, 2008 XStream Committers.
03: * All rights reserved.
04: *
05: * The software in this package is published under the terms of the BSD
06: * style license a copy of which has been included with this distribution in
07: * the LICENSE.txt file.
08: *
09: * Created on 22. October 2007 by Joerg Schaible
10: */
11: package com.thoughtworks.xstream;
12:
13: import com.thoughtworks.xstream.core.BaseException;
14:
15: /**
16: * Base exception for all thrown exceptions with XStream. JDK 1.3 friendly cause handling.
17: *
18: * @author Joe Walnes
19: * @author Jörg Schaible
20: * @since 1.3
21: */
22: public class XStreamException extends BaseException {
23:
24: private Throwable cause;
25:
26: /**
27: * Default constructor.
28: *
29: * @since 1.3
30: */
31: protected XStreamException() {
32: this ("", null);
33: }
34:
35: /**
36: * Constructs an XStreamException with a message.
37: *
38: * @param message
39: * @since 1.3
40: */
41: public XStreamException(String message) {
42: this (message, null);
43: }
44:
45: /**
46: * Constructs an XStreamException as wrapper for a different causing {@link Throwable}.
47: *
48: * @param cause
49: * @since 1.3
50: */
51: public XStreamException(Throwable cause) {
52: this ("", cause);
53: }
54:
55: /**
56: * Constructs an XStreamException with a message as wrapper for a different causing
57: * {@link Throwable}.
58: *
59: * @param message
60: * @param cause
61: * @since 1.3
62: */
63: public XStreamException(String message, Throwable cause) {
64: super (message
65: + (cause == null ? "" : " : " + cause.getMessage()));
66: this .cause = cause;
67: }
68:
69: public Throwable getCause() {
70: return cause;
71: }
72:
73: }
|