sbuild  1.6.10
Classes | Public Types | Public Member Functions | Static Protected Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
sbuild::error< T > Class Template Reference

Error exception class. More...

#include <sbuild-error.h>

+ Inheritance diagram for sbuild::error< T >:
+ Collaboration diagram for sbuild::error< T >:

Classes

struct  add_detail_helper
 Helper class to add detail to format string. More...
 
struct  add_detail_helper< A, true >
 Helper class to add detail to format string. More...
 
struct  add_reason_helper
 Helper class to add reason to reason string. More...
 
struct  add_reason_helper< A, true >
 Helper class to add reason to reason string. More...
 

Public Types

typedef T error_type
 The enum type providing the error codes for this type.
 
typedef std::map< error_type, const char * > map_type
 Mapping between error code and error description.
 

Public Member Functions

 error (std::string const &error)
 The constructor. More...
 
 error (std::string const &error, std::string const &reason)
 The constructor. More...
 
virtual ~error () throw ()
 The destructor.
 
- Public Member Functions inherited from sbuild::error_base
virtual ~error_base () throw ()
 The destructor.
 
virtual const char * why () const throw ()
 Get the reason for the error. More...
 
std::string const & get_reason () const
 Get the reason for the error. More...
 
void set_reason (std::string const &reason)
 Set the reason for the error. More...
 

Static Protected Member Functions

template<typename A , typename B , typename C , typename D , typename E , typename F >
static std::string format_error (A const &context1, B const &context2, C const &context3, error_type error, D const &detail1, E const &detail2, F const &detail3)
 Format an error message. More...
 
template<typename A , typename B , typename C , typename D , typename E , typename F >
static std::string format_error (A const &context1, B const &context2, C const &context3, std::runtime_error const &error, D const &detail1, E const &detail2, F const &detail3)
 Format an error message. More...
 
template<typename A , typename B , typename C , typename R , typename D , typename E , typename F >
static std::string format_reason (A const &context1, B const &context2, C const &context3, R const &error, D const &detail1, E const &detail2, F const &detail3)
 Format an reason string. More...
 
template<typename A >
static void add_detail (boost::format &fmt, A const &value)
 Add detail to format string. More...
 
template<typename A >
static void add_reason (std::string &reason, A const &value)
 Add reason to reason string. More...
 

Static Private Member Functions

static const char * get_error (error_type error)
 Get a translated error string. More...
 

Static Private Attributes

static map_type error_strings
 Mapping between error code and string.
 

Additional Inherited Members

- Protected Member Functions inherited from sbuild::error_base
 error_base (std::string const &error)
 The constructor. More...
 
 error_base (std::string const &error, std::string const &reason)
 The constructor. More...
 

Detailed Description

template<typename T>
class sbuild::error< T >

Error exception class.

Constructor & Destructor Documentation

template<typename T>
sbuild::error< T >::error ( std::string const &  error)
inline

The constructor.

Parameters
errorthe error message.
template<typename T>
sbuild::error< T >::error ( std::string const &  error,
std::string const &  reason 
)
inline

The constructor.

Parameters
errorthe error message.
reasonfurther information about the error

Member Function Documentation

template<typename T>
template<typename A >
static void sbuild::error< T >::add_detail ( boost::format &  fmt,
A const &  value 
)
staticprotected

Add detail to format string.

Parameters
fmtthe format string.
valuethe value to add.
template<typename T>
template<typename A >
static void sbuild::error< T >::add_reason ( std::string &  reason,
A const &  value 
)
staticprotected

Add reason to reason string.

Parameters
reasonthe reason string.
valuethe value to add.
template<typename T>
template<typename A , typename B , typename C , typename D , typename E , typename F >
static std::string sbuild::error< T >::format_error ( A const &  context1,
B const &  context2,
C const &  context3,
error_type  error,
D const &  detail1,
E const &  detail2,
F const &  detail3 
)
staticprotected

Format an error message.

Parameters
context1context of the error.
context2additional context of the error.
context3additional context of the error.
errorthe error code.
detail1details of the error.
detail2additional details of the error.
detail3additional details of the error.
Returns
a translated error message.
Todo:
Merge the logic shared between the two specialisations to prevent code duplication.
template<typename T>
template<typename A , typename B , typename C , typename D , typename E , typename F >
static std::string sbuild::error< T >::format_error ( A const &  context1,
B const &  context2,
C const &  context3,
std::runtime_error< T > const &  error,
D const &  detail1,
E const &  detail2,
F const &  detail3 
)
staticprotected

Format an error message.

Parameters
context1context of the error.
context2additional context of the error.
context3additional context of the error.
errorthe error code.
detail1details of the error.
detail2additional details of the error.
detail3additional details of the error.
Returns
a translated error message.
template<typename T>
template<typename A , typename B , typename C , typename R , typename D , typename E , typename F >
static std::string sbuild::error< T >::format_reason ( A const &  context1,
B const &  context2,
C const &  context3,
R const &  error,
D const &  detail1,
E const &  detail2,
F const &  detail3 
)
staticprotected

Format an reason string.

Parameters
context1context of the error.
context2additional context of the error.
context3additional context of the error.
errorthe error or error code.
detail1details of the error.
detail2additional details of the error.
detail3additional details of the error.
Returns
a translated error message.
template<typename T>
static const char* sbuild::error< T >::get_error ( error_type  error)
staticprivate

Get a translated error string.

Parameters
errorthe error code.
Returns
a translated error string.

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