40#ifndef _xmlwrapp_errors_h_
41#define _xmlwrapp_errors_h_
44#include "xmlwrapp/export.h"
50XMLWRAPP_MSVC_SUPPRESS_DLL_MEMBER_WARN
67class XMLWRAPP_INLINE_API
exception :
public std::runtime_error
70 explicit exception(
const std::string& what_arg)
71 : std::runtime_error(what_arg)
94 virtual void on_error(
const std::string& msg) = 0;
137extern XMLWRAPP_API error_handler_ignore_errors
ignore_errors;
168 : message_(err_msg), type_(msg_type)
175 const std::string&
message()
const {
return message_; }
178 std::string message_;
205 return messages_.empty();
243 bool has_errors_{
false};
244 bool has_warnings_{
false};
248inline exception::exception(
const error_messages& what_arg)
249 : std::runtime_error(what_arg.print())
256XMLWRAPP_MSVC_RESTORE_DLL_MEMBER_WARN
An error handler that ignores both errors and warnings.
Definition errors.h:107
void on_error(const std::string &) override
Called by xmlwrapp to report an error.
Definition errors.h:109
void on_warning(const std::string &) override
Called by xmlwrapp to report a warning.
Definition errors.h:110
Specialization of error_handler that throws on any error or warning.
Definition errors.h:131
void on_warning(const std::string &msg) override
Called by xmlwrapp to report a warning.
Definition errors.h:133
Specialization of error_handler that throws on any error.
Definition errors.h:119
void on_error(const std::string &msg) override
Called by xmlwrapp to report an error.
Definition errors.h:121
void on_warning(const std::string &) override
Called by xmlwrapp to report a warning.
Definition errors.h:122
The xml::error_handler class is used to handle libxml2 errors and warnings emitted during parsing,...
Definition errors.h:89
virtual void on_error(const std::string &msg)=0
Called by xmlwrapp to report an error.
virtual void on_warning(const std::string &msg)=0
Called by xmlwrapp to report a warning.
Single message in error_messages.
Definition errors.h:152
message_type
A type for different type of errors.
Definition errors.h:156
@ type_warning
warning
Definition errors.h:158
@ type_error
error
Definition errors.h:157
message_type type() const
Get the error message type.
Definition errors.h:172
error_message(const std::string &err_msg, message_type msg_type)
Create a new xml::error_message object.
Definition errors.h:167
const std::string & message() const
Get the error message.
Definition errors.h:175
The xml::error_messages class is used to store all the error messages which are collected while parsi...
Definition errors.h:190
bool has_errors() const
Check if there are any errors.
Definition errors.h:219
bool has_warnings() const
Check if there are warnings in the error messages.
Definition errors.h:214
const messages_type & messages() const
Get the error messages.
Definition errors.h:198
std::string print() const
Convert error messages into a single printable string.
void on_warning(const std::string &msg) override
Called by xmlwrapp to report a warning.
void on_error(const std::string &msg) override
Called by xmlwrapp to report an error.
std::list< error_message > messages_type
A type to store multiple messages.
Definition errors.h:193
virtual std::string format_for_print(const error_message &msg) const
Called by print() to format a single message.
bool empty() const
Convenience function to find if there are any messages at all.
Definition errors.h:203
This exception class is thrown by xmlwrapp for all runtime XML-related errors.
Definition errors.h:68
XML library namespace.
Definition attributes.h:55
error_handler_throw_on_error throw_on_error
Error handler object that throws on any error.
error_handler_throw_on_error_or_warning throw_on_error_or_warning
Error handler object that throws on any error or warning.
error_handler_ignore_errors ignore_errors
Error handler ignoring all errors, its use is strongly discouraged.