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

Error exception class. More...

#include <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 (const std::string &error)
 The constructor. More...
 
 error (const std::string &error, const std::string &reason)
 The constructor. More...
 
virtual ~error () throw ()
 The destructor.
 
template<typename A , typename B , typename C , typename D , typename E , typename F >
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)
 
template<typename A , typename B , typename C , typename D , typename E , typename F >
std::string format_error (A const &context1, B const &context2, C const &context3, const std::runtime_error &error, D const &detail1, E const &detail2, F const &detail3)
 
template<typename A >
void add_detail (boost::format &fmt, A const &value)
 
template<typename A , typename B , typename C , typename R , typename D , typename E , typename F >
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)
 
template<typename A >
void add_reason (std::string &reason, A const &value)
 
- 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 (const std::string &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, const std::runtime_error &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...
 
static void add_detail (boost::format &fmt, const std::nullptr_t &value)
 Add detail to format 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...
 

Private Member Functions

template<>
error< ctty_error_code >::map_type error_strings
 
template<>
error< keyfile::error_code >
::map_type 
error_strings
 
template<>
error< lock::error_code >::map_type error_strings
 
template<>
error< mntstream::error_code >
::map_type 
error_strings
 
template<>
error< parse_value_error_code >
::map_type 
error_strings
 
template<>
error
< sbuild::personality::error_code >
::map_type 
error_strings
 
template<>
error< run_parts::error_code >
::map_type 
error_strings
 
template<>
error< session::error_code >
::map_type 
error_strings
 
template<>
error< stat::error_code >::map_type error_strings
 

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 (const std::string &error)
 The constructor. More...
 
 error_base (const std::string &error, const std::string &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 ( const std::string &  error)
inline

The constructor.

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

The constructor.

Parameters
errorthe error message.
reasonfurther information about the error

Member Function Documentation

template<typename T >
void sbuild::error< T >::add_detail ( boost::format &  fmt,
const std::nullptr_t &  value 
)
inlinestaticprotected

Add detail to format string.

Specialised for nullptr. Current versions of boost::format don't like nullptr.

Parameters
fmtthe format string.
valuethe value to add.
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,
const std::runtime_error< T > &  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 >
const char * sbuild::error< T >::get_error ( error_type  error)
inlinestaticprivate

Get a translated error string.

Parameters
errorthe error code.
Returns
a translated error string.

References sbuild::gettext().


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