sbuild::error< T > Class Template Reference

Error exception class. More...

#include <sbuild-error.h>

Inheritance diagram for sbuild::error< T >:

Inheritance graph
[legend]
Collaboration diagram for sbuild::error< T >:

Collaboration graph
[legend]
List of all members.

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.
 error (std::string const &error, std::string const &reason)
 The constructor.
virtual ~error () throw ()
 The destructor.
template<>
sbuild::error< main::error_code
>::map_type 
error_strings (init_errors, init_errors+(sizeof(init_errors)/sizeof(init_errors[0])))
template<>
sbuild::error< main_base::error_code
>::map_type 
error_strings (init_errors, init_errors+(sizeof(init_errors)/sizeof(init_errors[0])))
template<>
sbuild::error< main::error_code
>::map_type 
error_strings (init_errors, init_errors+(sizeof(init_errors)/sizeof(init_errors[0])))

Static Protected Member Functions

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

Static Private Member Functions

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

Static Private Attributes

static map_type error_strings
 Mapping between error code and string.

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...

Detailed Description

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

Error exception class.

Definition at line 111 of file sbuild-error.h.


Member Typedef Documentation

template<typename T>
typedef T sbuild::error< T >::error_type

The enum type providing the error codes for this type.

Reimplemented in sbuild::custom_error< T >, and sbuild::parse_error< T >.

Definition at line 115 of file sbuild-error.h.

template<typename T>
typedef std::map<error_type,const char *> sbuild::error< T >::map_type

Mapping between error code and error description.

Definition at line 117 of file sbuild-error.h.


Constructor & Destructor Documentation

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

The constructor.

Parameters:
error the error message.

Definition at line 124 of file sbuild-error.h.

template<typename T>
sbuild::error< T >::error ( std::string const &  error,
std::string const &  reason 
) [inline]

The constructor.

Parameters:
error the error message.
reason further information about the error

Definition at line 135 of file sbuild-error.h.

template<typename T>
virtual sbuild::error< T >::~error (  )  throw () [inline, virtual]

The destructor.

Definition at line 142 of file sbuild-error.h.


Member Function Documentation

template<typename T>
static const char* sbuild::error< T >::get_error ( error_type  error  )  [static, private]

Get a translated error string.

Parameters:
error the error code.
Returns:
a translated error string.

template<typename T>
template<typename A, typename B, typename C, typename D, typename E>
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 
) [static, protected]

Format an error message.

Parameters:
context1 context of the error.
context2 additional context of the error.
context3 additional context of the error.
error the error code.
detail1 details of the error.
detail2 additional 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>
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 
) [static, protected]

Format an error message.

Parameters:
context1 context of the error.
context2 additional context of the error.
context3 additional context of the error.
error the error code.
detail1 details of the error.
detail2 additional 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>
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 
) [static, protected]

Format an reason string.

Parameters:
context1 context of the error.
context2 additional context of the error.
context3 additional context of the error.
error the error or error code.
detail1 details of the error.
detail2 additional details of the error.
Returns:
a translated error message.

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

Add detail to format string.

Parameters:
fmt the format string.
value the value to add.

template<typename T>
template<typename A>
static void sbuild::error< T >::add_reason ( std::string &  reason,
A const &  value 
) [static, protected]

Add reason to reason string.

Parameters:
reason the reason string.
value the value to add.

template<>
sbuild::error< main::error_code >::map_type sbuild::error< main::error_code >::error_strings ( init_errors  ,
init_errors (sizeof(init_errors)/sizeof(init_errors[0])) 
)

template<>
sbuild::error< main_base::error_code >::map_type sbuild::error< main_base::error_code >::error_strings ( init_errors  ,
init_errors (sizeof(init_errors)/sizeof(init_errors[0])) 
)

template<>
sbuild::error< main::error_code >::map_type sbuild::error< main::error_code >::error_strings ( init_errors  ,
init_errors (sizeof(init_errors)/sizeof(init_errors[0])) 
)


Member Data Documentation

template<typename T>
map_type sbuild::error< T >::error_strings [static, private]

Mapping between error code and string.

Definition at line 147 of file sbuild-error.h.


The documentation for this class was generated from the following file:
Generated on Sat Jan 27 16:14:09 2007 for schroot by  doxygen 1.5.1