MLIB
|
An error facility routes a group of errors handled in a similar manner. More...
#include <errorcode.h>
Public Member Functions | |
errfac (const std::string &name="Error") | |
Set defaults for log and throw levels. | |
void | throw_priority (erc::level pri) |
set throw priority | |
erc::level | throw_priority () const |
get throw priority | |
void | log_priority (erc::level pri) |
set log priority | |
erc::level | log_priority () const |
get log priority | |
virtual std::string | message (const erc &e) const |
return message to be logged | |
const std::string & | name () const |
get name | |
virtual void | raise (const erc &e) const |
Check if error must be logged or thrown. | |
virtual void | log (const erc &e) const |
Static Public Member Functions | |
static void | Default (errfac *f) |
set default facility | |
static errfac & | Default () |
get default facility | |
An error facility routes a group of errors handled in a similar manner.
To group handling of erc objects, each erc has associated a facility.
Instead of throwing an exception directly, the erc calls the facility's raise function. In turn, it is this function that decides what should happen erc based on facility's log level and throw level.
There is also a default facility that is used when the erc doesn't have an explicit facility.
|
inlinestatic |
set default facility
Change the default error facility.
If called with a NULL argument reverts to generic error facility
|
inlinevirtual |
Logging action. Default is to use stderr Message is "<facility name> - <erc message>\n"
Reimplemented in mlib::sock_facility.
|
inlinevirtual |
return message to be logged
Default message is "error <code>".
Reimplemented in mlib::sock_facility.
|
inlinevirtual |
Check if error must be logged or thrown.
This function is called by an active error (in destructor of erc objects or assignment operator).
The typical action chain is: erc destructor -> errfac::raise -> erc is thrown