libpqxx  v4.0-1
C++ library for PostgreSQL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pqxx::failure Class Reference

Run-time failure encountered by libpqxx, similar to std::runtime_error. More...

#include <except.hxx>

Inheritance diagram for pqxx::failure:
Collaboration diagram for pqxx::failure:

Public Member Functions

 failure (const PGSTD::string &)
 

Private Member Functions

virtual const PGSTD::exception & base () const throw ()
 Return std::exception base-class object. More...
 

Detailed Description

Run-time failure encountered by libpqxx, similar to std::runtime_error.

Constructor & Destructor Documentation

pqxx::failure::failure ( const PGSTD::string &  )
explicit

Member Function Documentation

virtual const PGSTD::exception& pqxx::failure::base ( ) const throw ()
inlineprivatevirtual

Return std::exception base-class object.

Use this to get at the exception's what() function, or to downcast to a more specific type using dynamic_cast.

Casting directly from pqxx_exception to a specific exception type is not likely to work since pqxx_exception is not (and could not safely be) derived from std::exception.

For example, to test dynamically whether an exception is an sql_error:

try
{
// ...
}
catch (const pqxx::pqxx_exception &e)
{
std::cerr << e.base().what() << std::endl;
const pqxx::sql_error *s=dynamic_cast<const pqxx::sql_error*>(&e.base());
if (s) std::cerr << "Query was: " << s->query() << std::endl;
}

Implements pqxx::pqxx_exception.


The documentation for this class was generated from the following file: