This commit was manufactured by cvs2svn to create branch 'gomp-branch'.
[official-gcc.git] / libjava / org / xml / sax / SAXException.java
blobb11d998edadc6bb4dba59b25a593336265c73df0
1 // SAX exception class.
2 // http://www.saxproject.org
3 // No warranty; no copyright -- use this as you will.
4 // $Id: SAXException.java,v 1.4.2.4 2002/01/29 21:34:14 dbrownell Exp $
6 package org.xml.sax;
8 /**
9 * Encapsulate a general SAX error or warning.
11 * <blockquote>
12 * <em>This module, both source code and documentation, is in the
13 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
14 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
15 * for further information.
16 * </blockquote>
18 * <p>This class can contain basic error or warning information from
19 * either the XML parser or the application: a parser writer or
20 * application writer can subclass it to provide additional
21 * functionality. SAX handlers may throw this exception or
22 * any exception subclassed from it.</p>
24 * <p>If the application needs to pass through other types of
25 * exceptions, it must wrap those exceptions in a SAXException
26 * or an exception derived from a SAXException.</p>
28 * <p>If the parser or application needs to include information about a
29 * specific location in an XML document, it should use the
30 * {@link org.xml.sax.SAXParseException SAXParseException} subclass.</p>
32 * @since SAX 1.0
33 * @author David Megginson
34 * @version 2.0.1 (sax2r2)
35 * @see org.xml.sax.SAXParseException
37 public class SAXException extends Exception {
40 /**
41 * Create a new SAXException.
43 public SAXException ()
45 super();
46 this.exception = null;
50 /**
51 * Create a new SAXException.
53 * @param message The error or warning message.
55 public SAXException (String message) {
56 super(message);
57 this.exception = null;
61 /**
62 * Create a new SAXException wrapping an existing exception.
64 * <p>The existing exception will be embedded in the new
65 * one, and its message will become the default message for
66 * the SAXException.</p>
68 * @param e The exception to be wrapped in a SAXException.
70 public SAXException (Exception e)
72 super();
73 this.exception = e;
77 /**
78 * Create a new SAXException from an existing exception.
80 * <p>The existing exception will be embedded in the new
81 * one, but the new exception will have its own message.</p>
83 * @param message The detail message.
84 * @param e The exception to be wrapped in a SAXException.
86 public SAXException (String message, Exception e)
88 super(message);
89 this.exception = e;
93 /**
94 * Return a detail message for this exception.
96 * <p>If there is an embedded exception, and if the SAXException
97 * has no detail message of its own, this method will return
98 * the detail message from the embedded exception.</p>
100 * @return The error or warning message.
102 public String getMessage ()
104 String message = super.getMessage();
106 if (message == null && exception != null) {
107 return exception.getMessage();
108 } else {
109 return message;
115 * Return the embedded exception, if any.
117 * @return The embedded exception, or null if there is none.
119 public Exception getException ()
121 return exception;
126 * Override toString to pick up any embedded exception.
128 * @return A string representation of this exception.
130 public String toString ()
132 if (exception != null) {
133 return exception.toString();
134 } else {
135 return super.toString();
141 //////////////////////////////////////////////////////////////////////
142 // Internal state.
143 //////////////////////////////////////////////////////////////////////
147 * @serial The embedded exception if tunnelling, or null.
149 private Exception exception;
153 // end of SAXException.java