1 /* 2 * Copyright (c) 2000 World Wide Web Consortium, 3 * (Massachusetts Institute of Technology, Institut National de 4 * Recherche en Informatique et en Automatique, Keio University). All 5 * Rights Reserved. This program is distributed under the W3C's Software 6 * Intellectual Property License. This program is distributed in the 7 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even 8 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 9 * PURPOSE. 10 * See W3C License http://www.w3.org/Consortium/Legal/ for more details. 11 */ 12 13 package org.w3c.dom; 14 15 /** 16 * DOM operations only raise exceptions in "exceptional" circumstances, i.e., 17 * when an operation is impossible to perform (either for logical reasons, 18 * because data is lost, or because the implementation has become unstable). 19 * In general, DOM methods return specific error values in ordinary 20 * processing situations, such as out-of-bound errors when using 21 * <code>NodeList</code>. 22 * <p>Implementations should raise other exceptions under other circumstances. 23 * For example, implementations should raise an implementation-dependent 24 * exception if a <code>null</code> argument is passed. 25 * <p>Some languages and object systems do not support the concept of 26 * exceptions. For such systems, error conditions may be indicated using 27 * native error reporting mechanisms. For some bindings, for example, 28 * methods may return error codes similar to those listed in the 29 * corresponding method descriptions. 30 * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>. 31 */ 32 public class DOMException extends RuntimeException { DOMException(short code, String message)33 public DOMException(short code, String message) { 34 super(message); 35 this.code = code; 36 } 37 /** @serial */ 38 public short code; 39 // ExceptionCode 40 /** 41 * If index or size is negative, or greater than the allowed value 42 */ 43 public static final short INDEX_SIZE_ERR = 1; 44 /** 45 * If the specified range of text does not fit into a DOMString 46 */ 47 public static final short DOMSTRING_SIZE_ERR = 2; 48 /** 49 * If any node is inserted somewhere it doesn't belong 50 */ 51 public static final short HIERARCHY_REQUEST_ERR = 3; 52 /** 53 * If a node is used in a different document than the one that created it 54 * (that doesn't support it) 55 */ 56 public static final short WRONG_DOCUMENT_ERR = 4; 57 /** 58 * If an invalid or illegal character is specified, such as in a name. See 59 * production 2 in the XML specification for the definition of a legal 60 * character, and production 5 for the definition of a legal name 61 * character. 62 */ 63 public static final short INVALID_CHARACTER_ERR = 5; 64 /** 65 * If data is specified for a node which does not support data 66 */ 67 public static final short NO_DATA_ALLOWED_ERR = 6; 68 /** 69 * If an attempt is made to modify an object where modifications are not 70 * allowed 71 */ 72 public static final short NO_MODIFICATION_ALLOWED_ERR = 7; 73 /** 74 * If an attempt is made to reference a node in a context where it does 75 * not exist 76 */ 77 public static final short NOT_FOUND_ERR = 8; 78 /** 79 * If the implementation does not support the requested type of object or 80 * operation. 81 */ 82 public static final short NOT_SUPPORTED_ERR = 9; 83 /** 84 * If an attempt is made to add an attribute that is already in use 85 * elsewhere 86 */ 87 public static final short INUSE_ATTRIBUTE_ERR = 10; 88 /** 89 * If an attempt is made to use an object that is not, or is no longer, 90 * usable. 91 * @since DOM Level 2 92 */ 93 public static final short INVALID_STATE_ERR = 11; 94 /** 95 * If an invalid or illegal string is specified. 96 * @since DOM Level 2 97 */ 98 public static final short SYNTAX_ERR = 12; 99 /** 100 * If an attempt is made to modify the type of the underlying object. 101 * @since DOM Level 2 102 */ 103 public static final short INVALID_MODIFICATION_ERR = 13; 104 /** 105 * If an attempt is made to create or change an object in a way which is 106 * incorrect with regard to namespaces. 107 * @since DOM Level 2 108 */ 109 public static final short NAMESPACE_ERR = 14; 110 /** 111 * If a parameter or an operation is not supported by the underlying 112 * object. 113 * @since DOM Level 2 114 */ 115 public static final short INVALID_ACCESS_ERR = 15; 116 117 } 118