Source code: com/aendvari/common/osm/OsmException.java
1 /*
2 * OsmException.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.osm;
11
12 /**
13 * <p>Thrown when a particular Object Space Model operation could not be performed. The specific
14 * error can be obtained from the <code>code</code> property. This exception is thrown only
15 * very in "exceptional" cases. Generally, OSM methods return specific error values in ordinary
16 * situations. </p>
17 *
18 * @author Trevor Milne
19 *
20 */
21
22 public class OsmException extends RuntimeException
23 {
24 /** Contains the specific error code for the exception. */
25 protected int code;
26
27 /** The exception that caused this exception, may be null. */
28 protected Throwable rootCause;
29
30
31 /* Constants. */
32
33
34 /** Defines the constants for the <code>code</code> property. */
35 public interface Code
36 {
37 /** The operation can not be performed. */
38 public static final int NotSupported = 1;
39
40 /** The value object could not be created. */
41 public static final int ValueNotCreated = 2;
42 }
43
44
45 /* Constructors. */
46
47
48 /**
49 * Creates a <code>OsmException</code> instance.
50 *
51 * @param setCode Code of specific error.
52 *
53 */
54
55 public OsmException(int setCode)
56 {
57 code = setCode;
58 }
59
60 /**
61 * Creates a <code>OsmException</code> instance.
62 *
63 * @param setCode Code of specific error.
64 * @param setRootCause The exception causing this exception.
65 *
66 */
67
68 public OsmException(int setCode, Throwable setRootCause)
69 {
70 code = setCode;
71 rootCause = setRootCause;
72 }
73
74
75 /* Accessors. */
76
77
78 /**
79 * Returns the exception that caused this exception, null if none.
80 *
81 */
82
83 public Throwable getRootCause()
84 {
85 return rootCause;
86 }
87
88 /**
89 * Returns a error code of the exception.
90 *
91 */
92
93 public int getCode()
94 {
95 return code;
96 }
97
98 /**
99 * Returns a string representation of the exception.
100 *
101 */
102
103 public String toString()
104 {
105 return (super.toString() + "; code=" + code + "; cause=" + rootCause);
106 }
107 }
108