1 ///////////////////////////////////////////////////////////////////////////////
2 /// \file regex_error.hpp
3 /// Contains the definition of the regex_error exception class.
5 // Copyright 2008 Eric Niebler. Distributed under the Boost
6 // Software License, Version 1.0. (See accompanying file
7 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_XPRESSIVE_REGEX_ERROR_HPP_EAN_10_04_2005
10 #define BOOST_XPRESSIVE_REGEX_ERROR_HPP_EAN_10_04_2005
12 // MS compatible compilers support #pragma once
19 #include <boost/throw_exception.hpp>
20 #include <boost/current_function.hpp>
21 #include <boost/exception/exception.hpp>
22 #include <boost/exception/info.hpp>
23 #include <boost/xpressive/regex_constants.hpp>
26 ///////////////////////////////////////////////////////////////////////////////
27 // This is a hack to get Doxygen to show the inheritance relation between
28 // regex_error and std::runtime_error.
29 #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
34 struct runtime_error {};
39 namespace boost { namespace xpressive
42 ////////////////////////////////////////////////////////////////////////////////
45 /// \brief The class regex_error defines the type of objects thrown as
46 /// exceptions to report errors during the conversion from a string representing
47 /// a regular expression to a finite state machine.
52 /// Constructs an object of class regex_error.
53 /// \param code The error_type this regex_error represents.
54 /// \param str The message string of this regex_error.
55 /// \post code() == code
56 explicit regex_error(regex_constants::error_type code, char const *str = "")
57 : std::runtime_error(str)
63 /// Accessor for the error_type value
64 /// \return the error_type code passed to the constructor
66 regex_constants::error_type code() const
71 /// Destructor for class regex_error
73 virtual ~regex_error() throw()
78 regex_constants::error_type code_;
85 , regex_constants::error_type code
94 #ifndef BOOST_EXCEPTION_DISABLE
95 boost::throw_exception(
96 boost::xpressive::regex_error(code, msg)
97 << boost::throw_function(fun)
98 << boost::throw_file(file)
99 << boost::throw_line((int)line)
102 boost::throw_exception(boost::xpressive::regex_error(code, msg));
109 #define BOOST_XPR_ENSURE_(pred, code, msg) \
110 boost::xpressive::detail::ensure_(!!(pred), code, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__) \
113 }} // namespace boost::xpressive