Source code: com/aendvari/common/model/ModelException.java
1 /*
2 * ModelException.java
3 *
4 * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5 *
6 * See the file LICENSE for terms of use.
7 *
8 */
9
10 package com.aendvari.common.model;
11
12 /**
13 * <p>Thrown when a particular Model operation could not be performed. The causing
14 * exception, if any, is available in the <code>exception</code> property. This
15 * exception does not have to be caught explictly. Generally, Model methods return
16 * specific error values during normal operation.</p>
17 *
18 * @author Trevor Milne
19 *
20 */
21
22 public class ModelException extends RuntimeException
23 {
24 /** The exception that caused this exception, may be null. */
25 protected Throwable rootCause;
26
27
28 /* Constructors. */
29
30
31 /**
32 * Creates a <code>ModelException</code> instance.
33 *
34 * @param setMessage String describing error.
35 *
36 */
37
38 public ModelException(String setMessage)
39 {
40 super(setMessage);
41 }
42
43 /**
44 * Creates a <code>ModelException</code> instance with a causing exception.
45 *
46 * @param setRootCause The exception causing this exception.
47 *
48 */
49
50 public ModelException(Throwable setRootCause)
51 {
52 rootCause = setRootCause;
53 }
54
55
56 /* Accessors. */
57
58
59 /**
60 * Returns the exception that caused this exception, null if none.
61 *
62 */
63
64 public Throwable getRootCause()
65 {
66 return rootCause;
67 }
68
69 /**
70 * Returns a string representation of the exception.
71 *
72 */
73
74 public String toString()
75 {
76 return (super.toString() + "; cause=" + rootCause);
77 }
78 }
79