1//
2// DOMException.cpp
3//
4// Library: XML
5// Package: DOM
6// Module: DOM
7//
8// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
9// and Contributors.
10//
11// SPDX-License-Identifier: BSL-1.0
12//
13
14
15#include "Poco/DOM/DOMException.h"
16#include <typeinfo>
17
18
19namespace Poco {
20namespace XML {
21
22
23const std::string DOMException::MESSAGES[_NUMBER_OF_MESSAGES] =
24{
25 "Invalid DOM exception code",
26 "Index or size is negative or greater than allowed value",
27 "The specified range of text does not fit into a DOMString",
28 "A node is inserted somewhere it doesn't belong",
29 "A node is used in a different document than the one that created it",
30 "An invalid character is specified",
31 "Data is specified for a node which does not support data",
32 "An attempt is made to modify an object where modifications are not allowed",
33 "An attempt was made to reference a node in a context where it does not exist",
34 "The implementation does not support the type of object requested",
35 "An attempt is made to add an attribute that is already in use elsewhere",
36 "A parameter or an operation is not supported by the underlying object",
37 "An invalid or illegal string is specified",
38 "An attempt is made to modify the type of the underlying object",
39 "An attempt is made to create or change an object in a way which is incorrect with regard to namespaces",
40 "An attempt is made to use an object that is not, or is no longer, usable"
41};
42
43
44DOMException::DOMException(unsigned short code):
45 XMLException(message(code)),
46 _code(code)
47{
48}
49
50
51DOMException::DOMException(const DOMException& exc):
52 XMLException(exc),
53 _code(exc._code)
54{
55}
56
57
58DOMException::~DOMException() throw()
59{
60}
61
62
63DOMException& DOMException::operator = (const DOMException& exc)
64{
65 if (&exc != this)
66 {
67 XMLException::operator = (exc);
68 _code = exc._code;
69 }
70 return *this;
71}
72
73
74const char* DOMException::name() const throw()
75{
76 return "DOMException";
77}
78
79
80const char* DOMException::className() const throw()
81{
82 return typeid(*this).name();
83}
84
85
86Poco::Exception* DOMException::clone() const
87{
88 return new DOMException(*this);
89}
90
91
92void DOMException::rethrow() const
93{
94 throw *this;
95}
96
97
98const std::string& DOMException::message(unsigned short code)
99{
100 if (code >= 1 && code < _NUMBER_OF_MESSAGES)
101 return MESSAGES[code];
102 else
103 return MESSAGES[0];
104}
105
106
107} } // namespace Poco::XML
108