Package nu.xom

# Class XMLException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
nu.xom.XMLException

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `NoSuchAttributeException`, `NoSuchChildException`, `UnavailableCharacterException`, `WellformednessException`

public class XMLException extends RuntimeException

The generic superclass for most runtime exceptions thrown in `nu.xom`. The general principle followed is that anything that can normally be detected by testing such as using spaces in an element name is a runtime exception. Exceptions that depend on environmental conditions, such as might occur when parsing an external file, are checked exceptions, because these depend on variable input, and thus all problems may not be detected during testing.

Version:
  1.1b3
Author:
  Elliotte Rusty Harold
See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`XMLException(String message)`
Creates a new `XMLException` with the specified detail message.
`XMLException(String message, Throwable cause)`
Creates a new `XMLException` with the specified detail message and an underlying root cause.

## Method Summary

Modifier and Type
Method
Description
`Throwable`
`getCause()`
Return the original cause that led to this exception, or null if there was no original exception.
`final Throwable`
`initCause(Throwable cause)`
Sets the root cause of this exception.

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### XMLException

public XMLException(String message, Throwable cause)

Creates a new `XMLException` with the specified detail message and an underlying root cause.

Parameters:
  `message` - information about the cause of the exception
  `cause` - the nested exception that caused this exception

### XMLException

public XMLException(String message)

Creates a new `XMLException` with the specified detail message.

Parameters:
  `message` - information about the cause of the exception

## Method Details

### getCause

public Throwable getCause()

Return the original cause that led to this exception, or null if there was no original exception.

Overrides:
  `getCause` in class `Throwable`
Returns:
  the root cause of this exception

### initCause

public final Throwable initCause(Throwable cause)

Sets the root cause of this exception. This may only be called once. Subsequent calls throw an `IllegalStateException`.

This method is unnecessary in Java 1.4 where it could easily be inherited from the superclass. However, including it here allows this method to be used in Java 1.3 and earlier.

Overrides:
  `initCause` in class `Throwable`
Parameters:
  `cause` - the root cause of this exception
Returns:
  this `XMLException`
Throws:
  `IllegalArgumentException` - if the cause is this exception (An exception cannot be its own cause.)
  `IllegalStateException` - if this method is called twice