| 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 | |
| 16 | |
| 17 | #ifndef DOM_DOMException_INCLUDED |
| 18 | #define DOM_DOMException_INCLUDED |
| 19 | |
| 20 | |
| 21 | #include "Poco/XML/XML.h" |
| 22 | #include "Poco/XML/XMLException.h" |
| 23 | |
| 24 | |
| 25 | namespace Poco { |
| 26 | namespace XML { |
| 27 | |
| 28 | |
| 29 | class XML_API DOMException: public XMLException |
| 30 | /// DOM operations only raise exceptions in "exceptional" circumstances, i.e., |
| 31 | /// when an operation is impossible to perform (either for logical reasons, |
| 32 | /// because data is lost, or because the implementation has become unstable). |
| 33 | /// In general, DOM methods return specific error values in ordinary processing |
| 34 | /// situations, such as out-of-bound errors when using NodeList. |
| 35 | /// |
| 36 | /// Implementations should raise other exceptions under other circumstances. |
| 37 | /// For example, implementations should raise an implementation-dependent exception |
| 38 | /// if a null argument is passed when null was not expected. |
| 39 | { |
| 40 | public: |
| 41 | enum |
| 42 | { |
| 43 | INDEX_SIZE_ERR = 1, /// index or size is negative or greater than allowed value |
| 44 | DOMSTRING_SIZE_ERR, /// the specified range of text does not fit into a DOMString (not used) |
| 45 | HIERARCHY_REQUEST_ERR, /// a node is inserted somewhere it doesn't belong |
| 46 | WRONG_DOCUMENT_ERR, /// a node is used in a different document than the one that created it |
| 47 | INVALID_CHARACTER_ERR, /// an invalid character is specified (not used) |
| 48 | NO_DATA_ALLOWED_ERR, /// data is specified for a node which does not support data |
| 49 | NO_MODIFICATION_ALLOWED_ERR, /// an attempt is made to modify an object where modifications are not allowed |
| 50 | NOT_FOUND_ERR, /// an attempt was made to reference a node in a context where it does not exist |
| 51 | NOT_SUPPORTED_ERR, /// the implementation does not support the type of object requested |
| 52 | INUSE_ATTRIBUTE_ERR, /// an attempt is made to add an attribute that is already in use elsewhere |
| 53 | INVALID_STATE_ERR, /// a parameter or an operation is not supported by the underlying object |
| 54 | SYNTAX_ERR, /// an invalid or illegal string is specified |
| 55 | INVALID_MODIFICATION_ERR, /// an attempt is made to modify the type of the underlying object |
| 56 | NAMESPACE_ERR, /// an attempt is made to create or change an object in a way which is incorrect with regard to namespaces |
| 57 | INVALID_ACCESS_ERR, /// an attempt is made to use an object that is not, or is no longer, usable |
| 58 | |
| 59 | _NUMBER_OF_MESSAGES |
| 60 | }; |
| 61 | |
| 62 | DOMException(unsigned short code); |
| 63 | /// Creates a DOMException with the given error code. |
| 64 | |
| 65 | DOMException(const DOMException& exc); |
| 66 | /// Creates a DOMException by copying another one. |
| 67 | |
| 68 | ~DOMException() throw(); |
| 69 | /// Destroys the DOMException. |
| 70 | |
| 71 | DOMException& operator = (const DOMException& exc); |
| 72 | |
| 73 | const char* name() const throw(); |
| 74 | /// Returns a static string describing the exception. |
| 75 | |
| 76 | const char* className() const throw(); |
| 77 | /// Returns the name of the exception class. |
| 78 | |
| 79 | Poco::Exception* clone() const; |
| 80 | /// Creates an exact copy of the exception. |
| 81 | |
| 82 | void rethrow() const; |
| 83 | /// (Re)Throws the exception. |
| 84 | |
| 85 | unsigned short code() const; |
| 86 | /// Returns the DOM exception code. |
| 87 | |
| 88 | protected: |
| 89 | static const std::string& message(unsigned short code); |
| 90 | |
| 91 | private: |
| 92 | DOMException(); |
| 93 | |
| 94 | unsigned short _code; |
| 95 | |
| 96 | static const std::string MESSAGES[_NUMBER_OF_MESSAGES]; |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | // |
| 101 | // inlines |
| 102 | // |
| 103 | inline unsigned short DOMException::code() const |
| 104 | { |
| 105 | return _code; |
| 106 | } |
| 107 | |
| 108 | |
| 109 | } } // namespace Poco::XML |
| 110 | |
| 111 | |
| 112 | #endif // DOM_DOMException_INCLUDED |
| 113 | |