1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2002-2006 Marcin Kalicinski
3 // Copyright (C) 2009 Sebastian Redl
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see www.boost.org
10 // ----------------------------------------------------------------------------
12 #ifndef BOOST_PROPERTY_TREE_EXCEPTIONS_HPP_INCLUDED
13 #define BOOST_PROPERTY_TREE_EXCEPTIONS_HPP_INCLUDED
15 #include <boost/property_tree/ptree_fwd.hpp>
17 #include <boost/any.hpp>
21 namespace boost { namespace property_tree
24 /// Base class for all property tree errors. Derives from
25 /// @c std::runtime_error. Call member function @c what to get human
26 /// readable message associated with the error.
27 class ptree_error : public std::runtime_error
30 /// Instantiate a ptree_error instance with the given message.
31 /// @param what The message to associate with this error.
32 ptree_error(const std::string &what);
34 ~ptree_error() throw();
38 /// Error indicating that translation from given value to the property tree
39 /// data_type (or vice versa) failed. Derives from ptree_error.
40 class ptree_bad_data : public ptree_error
43 /// Instantiate a ptree_bad_data instance with the given message and
45 /// @param what The message to associate with this error.
46 /// @param data The value associated with this error that was the source
47 /// of the translation failure.
48 template<class T> ptree_bad_data(const std::string &what,
51 ~ptree_bad_data() throw();
53 /// Retrieve the data associated with this error. This is the source
54 /// value that failed to be translated. You need to explicitly
56 template<class T> T data() const;
62 /// Error indicating that specified path does not exist. Derives from
64 class ptree_bad_path : public ptree_error
67 /// Instantiate a ptree_bad_path with the given message and path data.
68 /// @param what The message to associate with this error.
69 /// @param path The path that could not be found in the property_tree.
70 template<class T> ptree_bad_path(const std::string &what,
73 ~ptree_bad_path() throw();
75 /// Retrieve the invalid path. You need to explicitly specify the
77 template<class T> T path() const;
84 #include <boost/property_tree/detail/exception_implementation.hpp>