DOMException.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // DOMException.h
  3. //
  4. // Library: XML
  5. // Package: DOM
  6. // Module: DOM
  7. //
  8. // Definition of the DOM DOMException class.
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef DOM_DOMException_INCLUDED
  16. #define DOM_DOMException_INCLUDED
  17. #include "Poco/XML/XML.h"
  18. #include "Poco/XML/XMLException.h"
  19. namespace Poco {
  20. namespace XML {
  21. class XML_API DOMException: public XMLException
  22. /// DOM operations only raise exceptions in "exceptional" circumstances, i.e.,
  23. /// when an operation is impossible to perform (either for logical reasons,
  24. /// because data is lost, or because the implementation has become unstable).
  25. /// In general, DOM methods return specific error values in ordinary processing
  26. /// situations, such as out-of-bound errors when using NodeList.
  27. ///
  28. /// Implementations should raise other exceptions under other circumstances.
  29. /// For example, implementations should raise an implementation-dependent exception
  30. /// if a null argument is passed when null was not expected.
  31. {
  32. public:
  33. enum
  34. {
  35. INDEX_SIZE_ERR = 1, /// index or size is negative or greater than allowed value
  36. DOMSTRING_SIZE_ERR, /// the specified range of text does not fit into a DOMString (not used)
  37. HIERARCHY_REQUEST_ERR, /// a node is inserted somewhere it doesn't belong
  38. WRONG_DOCUMENT_ERR, /// a node is used in a different document than the one that created it
  39. INVALID_CHARACTER_ERR, /// an invalid character is specified (not used)
  40. NO_DATA_ALLOWED_ERR, /// data is specified for a node which does not support data
  41. NO_MODIFICATION_ALLOWED_ERR, /// an attempt is made to modify an object where modifications are not allowed
  42. NOT_FOUND_ERR, /// an attempt was made to reference a node in a context where it does not exist
  43. NOT_SUPPORTED_ERR, /// the implementation does not support the type of object requested
  44. INUSE_ATTRIBUTE_ERR, /// an attempt is made to add an attribute that is already in use elsewhere
  45. INVALID_STATE_ERR, /// a parameter or an operation is not supported by the underlying object
  46. SYNTAX_ERR, /// an invalid or illegal string is specified
  47. INVALID_MODIFICATION_ERR, /// an attempt is made to modify the type of the underlying object
  48. NAMESPACE_ERR, /// an attempt is made to create or change an object in a way which is incorrect with regard to namespaces
  49. INVALID_ACCESS_ERR, /// an attempt is made to use an object that is not, or is no longer, usable
  50. _NUMBER_OF_MESSAGES
  51. };
  52. DOMException(unsigned short code);
  53. /// Creates a DOMException with the given error code.
  54. DOMException(const DOMException& exc);
  55. /// Creates a DOMException by copying another one.
  56. ~DOMException() noexcept;
  57. /// Destroys the DOMException.
  58. DOMException& operator = (const DOMException& exc);
  59. const char* name() const noexcept;
  60. /// Returns a static string describing the exception.
  61. const char* className() const noexcept;
  62. /// Returns the name of the exception class.
  63. Poco::Exception* clone() const;
  64. /// Creates an exact copy of the exception.
  65. void rethrow() const;
  66. /// (Re)Throws the exception.
  67. unsigned short code() const;
  68. /// Returns the DOM exception code.
  69. protected:
  70. static const std::string& message(unsigned short code);
  71. private:
  72. DOMException();
  73. unsigned short _code;
  74. static const std::string MESSAGES[_NUMBER_OF_MESSAGES];
  75. };
  76. //
  77. // inlines
  78. //
  79. inline unsigned short DOMException::code() const
  80. {
  81. return _code;
  82. }
  83. } } // namespace Poco::XML
  84. #endif // DOM_DOMException_INCLUDED