4
// $Id: //poco/1.2/XML/include/Poco/SAX/SAXException.h#1 $
10
// SAX exception classes.
12
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
15
// Permission is hereby granted, free of charge, to any person or organization
16
// obtaining a copy of the software and accompanying documentation covered by
17
// this license (the "Software") to use, reproduce, display, distribute,
18
// execute, and transmit the Software, and to prepare derivative works of the
19
// Software, and to permit third-parties to whom the Software is furnished to
20
// do so, all subject to the following:
22
// The copyright notices in the Software and this entire statement, including
23
// the above license grant, this restriction and the following disclaimer,
24
// must be included in all copies of the Software, in whole or in part, and
25
// all derivative works of the Software, unless such copies or derivative
26
// works are solely in the form of machine-executable object code generated by
27
// a source language processor.
29
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35
// DEALINGS IN THE SOFTWARE.
39
#ifndef SAX_SAXException_INCLUDED
40
#define SAX_SAXException_INCLUDED
43
#include "Poco/XML/XML.h"
44
#include "Poco/XML/XMLException.h"
45
#include "Poco/XML/XMLString.h"
52
POCO_DECLARE_EXCEPTION(XML_API, SAXException, XMLException)
53
/// The base class for all SAX-related exceptions like SAXParseException,
54
/// SAXNotRecognizedException or SAXNotSupportedException.
56
/// This class can contain basic error or warning information from either the XML parser
57
/// or the application: a parser writer or application writer can subclass it to provide
58
/// additional functionality. SAX handlers may throw this exception or any exception subclassed
61
/// If the application needs to pass through other types of exceptions, it must wrap those exceptions
62
/// in a SAXException or an exception derived from a SAXException.
64
/// If the parser or application needs to include information about a specific location in an XML
65
/// document, it should use the SAXParseException subclass.
68
POCO_DECLARE_EXCEPTION(XML_API, SAXNotRecognizedException, SAXException)
69
/// Exception class for an unrecognized identifier.
71
/// An XMLReader will throw this exception when it finds an unrecognized feature or property
72
/// identifier; SAX applications and extensions may use this class for other, similar purposes.
75
POCO_DECLARE_EXCEPTION(XML_API, SAXNotSupportedException, SAXException)
76
/// Exception class for an unsupported operation.
78
/// An XMLReader will throw this exception when it recognizes a feature or property identifier,
79
/// but cannot perform the requested operation (setting a state or value). Other SAX2 applications
80
/// and extensions may use this class for similar purposes.
86
class XML_API SAXParseException: public SAXException
87
/// Encapsulate an XML parse error or warning.
89
/// This exception may include information for locating the error in the original XML document,
90
/// as if it came from a Locator object. Note that although the application will receive a
91
/// SAXParseException as the argument to the handlers in the ErrorHandler interface, the application
92
/// is not actually required to throw the exception; instead, it can simply read the information in it
93
/// and take a different action.
95
/// Since this exception is a subclass of SAXException, it inherits the ability to wrap another exception.
98
SAXParseException(const std::string& msg, const Locator& loc);
99
/// Create a new SAXParseException from a message and a Locator.
101
SAXParseException(const std::string& msg, const Locator& loc, const Poco::Exception& exc);
102
/// Wrap an existing exception in a SAXParseException.
104
SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber);
105
/// Create a new SAXParseException with an embedded exception.
107
/// This constructor is most useful for parser writers.
108
/// All parameters except the message are as if they were provided by a Locator.
109
/// For example, if the system identifier is a URL (including relative filename),
110
/// the caller must resolve it fully before creating the exception.
112
SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber, const Poco::Exception& exc);
113
/// Create a new SAXParseException.
115
/// This constructor is most useful for parser writers.
116
/// All parameters except the message are as if they were provided by a Locator.
117
/// For example, if the system identifier is a URL (including relative filename),
118
/// the caller must resolve it fully before creating the exception.
120
SAXParseException(const SAXParseException& exc);
121
/// Creates a new SAXParseException from another one.
123
~SAXParseException() throw();
124
/// Destroy the exception.
126
SAXParseException& operator = (const SAXParseException& exc);
127
/// Assignment operator.
129
const char* name() const throw();
130
/// Returns a static string describing the exception.
132
const char* className() const throw();
133
/// Returns the name of the exception class.
135
Poco::Exception* clone() const;
136
/// Creates an exact copy of the exception.
138
void rethrow() const;
139
/// (Re)Throws the exception.
141
const XMLString& getPublicId() const;
142
/// Get the public identifier of the entity where the exception occurred.
144
const XMLString& getSystemId() const;
145
/// Get the system identifier of the entity where the exception occurred.
147
int getLineNumber() const;
148
/// The line number of the end of the text where the exception occurred.
149
/// The first line is line 1.
151
int getColumnNumber() const;
152
/// The column number of the end of the text where the exception occurred.
153
/// The first column in a line is position 1.
156
static std::string buildMessage(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber);
171
inline const XMLString& SAXParseException::getPublicId() const
177
inline const XMLString& SAXParseException::getSystemId() const
183
inline int SAXParseException::getLineNumber() const
189
inline int SAXParseException::getColumnNumber() const
191
return _columnNumber;
195
} } // namespace Poco::XML
198
#endif // SAX_SAXException_INCLUDED