1//
2// ErrorHandler.h
3//
4// Library: XML
5// Package: SAX
6// Module: SAX
7//
8// SAX ErrorHandler Interface.
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 SAX_ErrorHandler_INCLUDED
18#define SAX_ErrorHandler_INCLUDED
19
20
21#include "Poco/XML/XML.h"
22
23
24namespace Poco {
25namespace XML {
26
27
28class SAXException;
29
30
31class XML_API ErrorHandler
32 /// If a SAX application needs to implement customized error handling, it must
33 /// implement this interface and then register an instance with the XML reader
34 /// using the setErrorHandler method. The parser will then report all errors and
35 /// warnings through this interface.
36 ///
37 /// WARNING: If an application does not register an ErrorHandler, XML parsing errors
38 /// will go unreported, except that SAXParseExceptions will be thrown for fatal errors.
39 /// In order to detect validity errors, an ErrorHandler that does something with error()
40 /// calls must be registered.
41 ///
42 /// For XML processing errors, a SAX driver must use this interface in preference to
43 /// throwing an exception: it is up to the application to decide whether to throw an
44 /// exception for different types of errors and warnings. Note, however, that there is no
45 /// requirement that the parser continue to report additional errors after a call to
46 /// fatalError. In other words, a SAX driver class may throw an exception after reporting
47 /// any fatalError. Also parsers may throw appropriate exceptions for non-XML errors. For
48 /// example, XMLReader::parse() would throw an IOException for errors accessing entities or
49 /// the document.
50{
51public:
52 virtual void warning(const SAXException& exc) = 0;
53 /// Receive notification of a warning.
54 ///
55 /// SAX parsers will use this method to report conditions that are not errors or fatal
56 /// errors as defined by the XML recommendation. The default behaviour is to take no action.
57 ///
58 /// The SAX parser must continue to provide normal parsing events after invoking this method:
59 /// it should still be possible for the application to process the document through to the end.
60 ///
61 /// Filters may use this method to report other, non-XML warnings as well.
62
63 virtual void error(const SAXException& exc) = 0;
64 /// Receive notification of a recoverable error.
65 ///
66 /// This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0
67 /// Recommendation. For example, a validating parser would use this callback to report
68 /// the violation of a validity constraint. The default behaviour is to take no action.
69 ///
70 /// The SAX parser must continue to provide normal parsing events after invoking this
71 /// method: it should still be possible for the application to process the document through
72 /// to the end. If the application cannot do so, then the parser should report a fatal error
73 /// even if the XML recommendation does not require it to do so.
74 ///
75 /// Filters may use this method to report other, non-XML errors as well.
76
77 virtual void fatalError(const SAXException& exc) = 0;
78 /// Receive notification of a non-recoverable error.
79 /// The application must assume that the document is unusable after the parser has
80 /// invoked this method, and should continue (if at all) only for the sake of collecting
81 /// additional error messages: in fact, SAX parsers are free to stop reporting any other
82 /// events once this method has been invoked.
83
84protected:
85 virtual ~ErrorHandler();
86};
87
88
89} } // namespace Poco::XML
90
91
92#endif // SAX_ErrorHandler_INCLUDED
93