Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/org/w3c/dom/DOMException#constants) \| [Fields](https://developer.android.com/reference/org/w3c/dom/DOMException#lfields) \| [Ctors](https://developer.android.com/reference/org/w3c/dom/DOMException#pubctors) \| [Inherited Methods](https://developer.android.com/reference/org/w3c/dom/DOMException#inhmethods)

# DOMException

` public class DOMException `   
` ` ` ` ` ` ` extends https://developer.android.com/reference/java/lang/RuntimeException ` ` `

|---|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||||
| ↳ | [java.lang.Throwable](https://developer.android.com/reference/java/lang/Throwable) ||||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/java/lang/Exception) |||
|   |   | ↳ | [java.lang.RuntimeException](https://developer.android.com/reference/java/lang/RuntimeException) ||
|   |   |   | ↳ | org.w3c.dom.DOMException |

<br />

*** ** * ** ***

DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impossible to perform (either for logical reasons, because data is lost, or because the implementation has become unstable). In general, DOM methods return specific error values in ordinary processing situations, such as out-of-bound errors when using `NodeList`.

Implementations should raise other exceptions under other circumstances. For example, implementations should raise an implementation-dependent exception if a `null` argument is passed when `null` was not expected.

Some languages and object systems do not support the concept of exceptions. For such systems, error conditions may be indicated using native error reporting mechanisms. For some bindings, for example, methods may return error codes similar to those listed in the corresponding method descriptions.

See also the [Document Object Model (DOM) Level 3 Core Specification](http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407).

## Summary

| ### Constants ||
|---|---|
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#DOMSTRING_SIZE_ERR` If the specified range of text does not fit into a `DOMString`. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#HIERARCHY_REQUEST_ERR` If any `Node` is inserted somewhere it doesn't belong. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#INDEX_SIZE_ERR` If index or size is negative, or greater than the allowed value. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#INUSE_ATTRIBUTE_ERR` If an attempt is made to add an attribute that is already in use elsewhere. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#INVALID_ACCESS_ERR` If a parameter or an operation is not supported by the underlying object. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#INVALID_CHARACTER_ERR` If an invalid or illegal character is specified, such as in an XML name. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#INVALID_MODIFICATION_ERR` If an attempt is made to modify the type of the underlying object. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#INVALID_STATE_ERR` If an attempt is made to use an object that is not, or is no longer, usable. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#NAMESPACE_ERR` If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#NOT_FOUND_ERR` If an attempt is made to reference a `Node` in a context where it does not exist. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#NOT_SUPPORTED_ERR` If the implementation does not support the requested type of object or operation. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#NO_DATA_ALLOWED_ERR` If data is specified for a `Node` which does not support data. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#NO_MODIFICATION_ALLOWED_ERR` If an attempt is made to modify an object where modifications are not allowed. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#SYNTAX_ERR` If an invalid or illegal string is specified. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#TYPE_MISMATCH_ERR` If the type of an object is incompatible with the expected type of the parameter associated to the object. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#VALIDATION_ERR` If a call to a method such as `insertBefore` or `removeChild` would make the `Node` invalid with respect to "partial validity", this exception would be raised and the operation would not be done. |
| `short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#WRONG_DOCUMENT_ERR` If a `Node` is used in a different document than the one that created it (that doesn't support it). |

| ### Fields ||
|---|---|
| ` public short` | `https://developer.android.com/reference/org/w3c/dom/DOMException#code` <br /> |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/org/w3c/dom/DOMException#DOMException(short,%20java.lang.String)(short code, https://developer.android.com/reference/java/lang/String message) ` |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Throwable ` ` final void` ` https://developer.android.com/reference/java/lang/Throwable#addSuppressed(java.lang.Throwable)(https://developer.android.com/reference/java/lang/Throwable exception) `

Appends the specified exception to the exceptions that were suppressed in order to deliver this exception.
` https://developer.android.com/reference/java/lang/Throwable` ` https://developer.android.com/reference/java/lang/Throwable#fillInStackTrace()() `

Fills in the execution stack trace.
` https://developer.android.com/reference/java/lang/Throwable` ` https://developer.android.com/reference/java/lang/Throwable#getCause()() `

Returns the cause of this throwable or `null` if the cause is nonexistent or unknown.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Throwable#getLocalizedMessage()() `

Creates a localized description of this throwable.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Throwable#getMessage()() `

Returns the detail message string of this throwable.
` https://developer.android.com/reference/java/lang/StackTraceElement` ` https://developer.android.com/reference/java/lang/Throwable#getStackTrace()() `

Provides programmatic access to the stack trace information printed by `https://developer.android.com/reference/java/lang/Throwable#printStackTrace()`.
` final https://developer.android.com/reference/java/lang/Throwable` ` https://developer.android.com/reference/java/lang/Throwable#getSuppressed()() `

Returns an array containing all of the exceptions that were suppressed, typically by the `try`-with-resources statement, in order to deliver this exception.
` https://developer.android.com/reference/java/lang/Throwable` ` https://developer.android.com/reference/java/lang/Throwable#initCause(java.lang.Throwable)(https://developer.android.com/reference/java/lang/Throwable cause) `

Initializes the *cause* of this throwable to the specified value.
` void` ` https://developer.android.com/reference/java/lang/Throwable#printStackTrace()() `

Prints this throwable and its backtrace to the standard error stream.
` void` ` https://developer.android.com/reference/java/lang/Throwable#printStackTrace(java.io.PrintWriter)(https://developer.android.com/reference/java/io/PrintWriter s) `

Prints this throwable and its backtrace to the specified print writer.
` void` ` https://developer.android.com/reference/java/lang/Throwable#printStackTrace(java.io.PrintStream)(https://developer.android.com/reference/java/io/PrintStream s) `

Prints this throwable and its backtrace to the specified print stream.
` void` ` https://developer.android.com/reference/java/lang/Throwable#setStackTrace(java.lang.StackTraceElement[])(https://developer.android.com/reference/java/lang/StackTraceElement stackTrace) `

Sets the stack trace elements that will be returned by `https://developer.android.com/reference/java/lang/Throwable#getStackTrace()` and printed by `https://developer.android.com/reference/java/lang/Throwable#printStackTrace()` and related methods.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Throwable#toString()() `

Returns a short description of this throwable.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### DOMSTRING_SIZE_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short DOMSTRING_SIZE_ERR
```

If the specified range of text does not fit into a `DOMString`.

<br />

Constant Value: 2 (0x00000002)

### HIERARCHY_REQUEST_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short HIERARCHY_REQUEST_ERR
```

If any `Node` is inserted somewhere it doesn't belong.

<br />

Constant Value: 3 (0x00000003)

### INDEX_SIZE_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short INDEX_SIZE_ERR
```

If index or size is negative, or greater than the allowed value.

<br />

Constant Value: 1 (0x00000001)

### INUSE_ATTRIBUTE_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short INUSE_ATTRIBUTE_ERR
```

If an attempt is made to add an attribute that is already in use elsewhere.

<br />

Constant Value: 10 (0x0000000a)

### INVALID_ACCESS_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short INVALID_ACCESS_ERR
```

If a parameter or an operation is not supported by the underlying object.

<br />

Constant Value: 15 (0x0000000f)

### INVALID_CHARACTER_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short INVALID_CHARACTER_ERR
```

If an invalid or illegal character is specified, such as in an XML name.

<br />

Constant Value: 5 (0x00000005)

### INVALID_MODIFICATION_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short INVALID_MODIFICATION_ERR
```

If an attempt is made to modify the type of the underlying object.

<br />

Constant Value: 13 (0x0000000d)

### INVALID_STATE_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short INVALID_STATE_ERR
```

If an attempt is made to use an object that is not, or is no longer, usable.

<br />

Constant Value: 11 (0x0000000b)

### NAMESPACE_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short NAMESPACE_ERR
```

If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces.

<br />

Constant Value: 14 (0x0000000e)

### NOT_FOUND_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short NOT_FOUND_ERR
```

If an attempt is made to reference a `Node` in a context where it does not exist.

<br />

Constant Value: 8 (0x00000008)

### NOT_SUPPORTED_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short NOT_SUPPORTED_ERR
```

If the implementation does not support the requested type of object or operation.

<br />

Constant Value: 9 (0x00000009)

### NO_DATA_ALLOWED_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short NO_DATA_ALLOWED_ERR
```

If data is specified for a `Node` which does not support data.

<br />

Constant Value: 6 (0x00000006)

### NO_MODIFICATION_ALLOWED_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short NO_MODIFICATION_ALLOWED_ERR
```

If an attempt is made to modify an object where modifications are not allowed.

<br />

Constant Value: 7 (0x00000007)

### SYNTAX_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short SYNTAX_ERR
```

If an invalid or illegal string is specified.

<br />

Constant Value: 12 (0x0000000c)

### TYPE_MISMATCH_ERR

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short TYPE_MISMATCH_ERR
```

If the type of an object is incompatible with the expected type of the parameter associated to the object.

<br />

Constant Value: 17 (0x00000011)

### VALIDATION_ERR

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short VALIDATION_ERR
```

If a call to a method such as `insertBefore` or `removeChild` would make the `Node` invalid with respect to "partial validity", this exception would be raised and the operation would not be done. This code is used in \[[DOM Level 3 Validation](http://www.w3.org/TR/2004/REC-DOM-Level-3-Val-20040127/)\] . Refer to this specification for further information.

<br />

Constant Value: 16 (0x00000010)

### WRONG_DOCUMENT_ERR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short WRONG_DOCUMENT_ERR
```

If a `Node` is used in a different document than the one that created it (that doesn't support it).

<br />

Constant Value: 4 (0x00000004)

## Fields

### code

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public short code
```

<br />

<br />

## Public constructors

### DOMException

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public DOMException (short code, 
                String message)
```

<br />

<br />

| Parameters ||
|---|---|
| `code` | `short` <br /> |
| `message` | `String` <br /> |