ErrorHandler.h 3.5 KB

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