KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > arooa > ArooaException


1 package org.oddjob.arooa;
2
3 /**
4  * An exception used when creation fails.
5  */

6 public class ArooaException extends RuntimeException JavaDoc {
7
8     /** Location in the build file where the exception occurred */
9     private Location location = Location.UNKNOWN_LOCATION;
10
11     public ArooaException() {
12     }
13
14     public ArooaException(String JavaDoc message) {
15         super(message);
16     }
17     
18     public ArooaException(String JavaDoc message, Throwable JavaDoc t) {
19         super(message, t);
20     }
21     
22     public ArooaException(Throwable JavaDoc t) {
23         super(t);
24     }
25     
26     public Throwable JavaDoc getException() {
27         return getCause();
28     }
29
30     /**
31      * Constructs an exception with the given exception as
32      * a root cause and a location in a file.
33      *
34      * @param cause The exception that might have caused this one.
35      * Should not be <code>null</code>.
36      * @param location The location in the xml file where the error
37      * occurred. Must not be <code>null</code>.
38      */

39     public ArooaException(Throwable JavaDoc cause, Location location) {
40         this(cause);
41         this.location = location;
42     }
43     
44     /**
45      * Constructs an exception with the given message and exception as
46      * a root cause and a location in a file.
47      *
48      * @param msg A description of or information about the exception.
49      * Should not be <code>null</code> unless a cause is specified.
50      * @param cause The exception that might have caused this one.
51      * May be <code>null</code>.
52      * @param location The location in the xml file where the error
53      * occurred. Must not be <code>null</code>.
54      */

55     public ArooaException(String JavaDoc msg, Throwable JavaDoc cause, Location location) {
56         this(msg, cause);
57         this.location = location;
58     }
59
60     
61     /**
62      * Returns the location of the error and the error message.
63      *
64      * @return the location of the error and the error message
65      */

66     public String JavaDoc toString() {
67         return location.toString() + getMessage();
68     }
69
70     /**
71      * Sets the file location where the error occurred.
72      *
73      * @param location The file location where the error occurred.
74      * Must not be <code>null</code>.
75      */

76     public void setLocation(Location location) {
77         this.location = location;
78     }
79
80     /**
81      * Returns the file location where the error occurred.
82      *
83      * @return the file location where the error occurred.
84      */

85     public Location getLocation() {
86         return location;
87     }
88
89 }
90
Popular Tags