MLIB
Loading...
Searching...
No Matches
mlib::errfac Class Reference

An error facility routes a group of errors handled in a similar manner. More...

#include <errorcode.h>

Inheritance diagram for mlib::errfac:
mlib::sock_facility

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 errfacDefault ()
 get default facility
 

Detailed Description

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.

Member Function Documentation

◆ Default()

void mlib::errfac::Default ( errfac facility)
inlinestatic

set default facility

Change the default error facility.

If called with a NULL argument reverts to generic error facility

◆ log()

void mlib::errfac::log ( const erc e) const
inlinevirtual

Logging action. Default is to use stderr Message is "<facility name> - <erc message>\n"

Reimplemented in mlib::sock_facility.

◆ message()

std::string mlib::errfac::message ( const erc e) const
inlinevirtual

return message to be logged

Default message is "error <code>".

Reimplemented in mlib::sock_facility.

◆ raise()

void mlib::errfac::raise ( const erc e) const
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


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