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