Section 25.82. DOMException: signal exceptions or errors for core DOM objects


25.82. DOMException: signal exceptions or errors for core DOM objects

DOM Level 1 Core: Object DOMException

25.82.1. Constants

The following constants define the legal values for the code property of a DOMException object. Note that these constants are static properties of DOMException, not properties of individual exception objects:


unsigned short INDEX_SIZE_ERR = 1

Indicates an out-of-bounds error for an array or string index.


unsigned short DOMSTRING_SIZE_ERR = 2

Indicates that a requested text is too big to fit into a string in the current JavaScript implementation.


unsigned short HIERARCHY_REQUEST_ERR = 3

Indicates that an attempt was made to place a node somewhere illegal in the document-tree hierarchy.


unsigned short WRONG_DOCUMENT_ERR = 4

Indicates an attempt to use a node with a document that is different from the document that created the node.


unsigned short INVALID_CHARACTER_ERR = 5

Indicates that an illegal character is used (in an element name, for example).


unsigned short NO_DATA_ALLOWED_ERR = 6

Not currently used.


unsigned short NO_MODIFICATION_ALLOWED_ERR = 7

Indicates that an attempt was made to modify a node that is read-only and does not allow modifications.


unsigned short NOT_FOUND_ERR = 8

Indicates that a node was not found where it was expected.


unsigned short NOT_SUPPORTED_ERR = 9

Indicates that a method or property is not supported in the current DOM implementation.


unsigned short INUSE_ATTRIBUTE_ERR = 10

Indicates that an attempt was made to associate an Attr with an Element when that Attr node was already associated with a different Element node.


unsigned short INVALID_STATE_ERR = 11 [DOM Level 2]

Indicates an attempt to use an object that is not yet, or is no longer, in a state that allows such use.


unsigned short SYNTAX_ERR = 12 [DOM Level 2]

Indicates that a specified string contains a syntax error. Commonly used with CSS property specifications.


unsigned short INVALID_MODIFICATION_ERR = 13 [DOM Level 2]

Indicates an attempt to modify the type of a CSSRule or CSSValue object.


unsigned short NAMESPACE_ERR = 14 [DOM Level 2]

Indicates an error involving element or attribute namespaces.


unsigned short INVALID_ACCESS_ERR = 15 [DOM Level 2]

Indicates an attempt to access an object in a way that is not supported by the implementation.

25.82.2. Properties


unsigned short code

An error code that provides some detail about what caused the exception. The legal values (and their meanings) for this property are defined by the constants just listed.

25.82.3. Description

A DOMException object is thrown when a DOM method or property is used incorrectly or in an inappropriate context. The value of the code property indicates the general type of exception that occurred. Note that a DOMException may be thrown when reading or writing a property of an object as well as when calling a method of an object.

The descriptions of object properties and methods in this reference include a list of exception types they may throw. Note, however, that certain commonly thrown exceptions are omitted from these lists. A DOMException with a code of NO_MODIFICATION_ALLOWED_ERR is thrown any time an attempt is made to modify a read-only node. Thus, most methods and read/write properties of the Node interface (and of its subinterfaces) may throw this exception. Because read-only nodes appear only in XML documents and not in HTML documents, and because it applies so universally to the methods and writable properties of Node objects, the NO_MODIFICATION_ALLOWED_ERR exception is omitted from the descriptions of those methods and properties.

Similarly, many DOM methods and properties that return strings may throw a DOMException with a code of DOMSTRING_SIZE_ERR, which indicates that the text to be returned is too long to be represented as a string value in the underlying JavaScript implementation. Although this type of exception may theoretically be thrown by many properties and methods, it is very rare in practice and is omitted from the descriptions of those methods and properties.

Note that not all exceptions in the DOM are signaled with a DOMException: exceptions involving the DOM Range module cause a RangeException to be thrown.

25.82.4. See Also

RangeException




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net