# Boost Exception

### exception

#include <boost/exception/exception.hpp>

    namespace
    boost
        {
        class
        exception
            {
            public:

            virtual char const * diagnostic_information() const throw();

            protected:

            exception();
            exception( exception const & x );
            ~exception();
            };
        }

Class boost::exception is designed to be used as a universal base for user-defined exception types.

An object of any type deriving from boost::exception can store data of arbitrary types, using the error_info wrapper and operator<<.

To retrieve data from a boost::exception object, use the get_error_info function template.

### exception::exception

    exception();
    exception( exception const & x );

#### Effects:

- Default constructor: initializes an empty boost::exception object.
- Copy constructor: initializes a boost::exception object which shares with x all data added through operator<<, including data that is added at a future time.

#### Throws:

Nothing.

### exception::~exception

    ~exception();

#### Effects:

Frees all resources associated with a boost::exception object.

#### Throws:

Nothing.

### exception::diagnostic_information

    virtual char const * diagnostic_information() const throw();

#### Returns:

A string representation of all data stored in the boost::exception object by the operator<< function. See "Diagnostic Information" for details.

#### Throws:

Nothing.

#### Notes:

- The return value remains valid until the exception object from which it was obtained is destroyed or modified.
- The header boost/exception/diagnostic_information.hpp provides a namespace-scope function diagnostic_information which takes a std::exception. It calls exception::diagnostic_information if its argument can be converted to boost::exception; otherwise it returns a string that combines the value of std::exception::what and the exception's dynamic type.

### See Also:

BOOST_ERROR_INFO
Boost Exception
boost/exception/exception.hpp
current_exception
Diagnostic Information
diagnostic_information
enable_current_exception
enable_error_info
error_info
exception::diagnostic_information
exception::exception
exception::~exception
get_error_info
Integrating Boost Exception in Existing Exception Class Hierarchies
operator<</exception
operator<</tuple
Transporting of Arbitrary Data to the Catch Site
Transporting of Exceptions Between Threads
unknown_exception