class Error

Class For Handling Error Messages. More...

Full nameStatusMsgs::Error
Definition#include <status.H>
InheritsStatusMsgs::StatusMsg [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods


Detailed Description

The Error class is a superset of StatusMsg responsible for handling error messages which can have different levels of severity. This class gives an easy object oriented way of handling errors within a program and is found to be much easier to deal with compared to exceptions.

Chances are all error messages within a program will want to be directed to one particular output and have the same header, therefore the Error ostream and error message header has been defined as global. This allows for the ability to easily redefine the location of error outputs for all Error objects with just one method call to setOutput .

see StatusMsgs::ErrLevel

 Error (const string hdr = eheader, const string border = eboarder)

Set Error to default header. The header size is automatically assigned with the length of the hdr string, and by default creation this object is assigned the ErrLevel of SUCCESS which has an error number of 0.

Parameters:
hdrDefault header
borderDefault header border

See also: StatusMsgs, StatusMsg

 Error (const Error& err)

Copy constructor

Error&  operator= (const Error& err)

Copy assignment which has the special purpose of making sure that if an error exists in the original or new object, then the error with the greatest severity is maintained.

operator  bool ()

[const]

Conversion operator to return error status for assignments requiring a boolean value. A way to understand this operator is for example "if(!err)" is "if no error then" and "if(err)" is "if error then".

Returns: true if error and false otherwise

operator  int ()

[const]

Conversion operator to return the error number for assignments requiring an integer value. This is very useful in returning the error status of a program at termination.

Returns: Error status number (Success = 0 or Error > 0)

operator  ErrLevel ()

[const]

Conversion operator to return the error level for assignments requiring an enum ErrLevel value. This is neccessary for doing compare expression with ErrLevel values, such as "if(err == MINOR) {...}".

see ErrLevel

Returns: Error level

void  operator() (const ErrLevel& level, string msg = SM_DBODY, string arg = SM_NULL, ostream& out = *eout)

This method allows for "err(ErrLevel,message)" operations to specify the error message along with an error level, or if a message argument is not available, it instead only updates the current error level along with actions. This method takes different actions depending on the ErrLevel passed to it:


 SUCCESS : Sets object to original successful state.
 MINOR   : If msg argument exists, it sets the status message body.
           Then it sets or updates the error number to MINOR.
 MAJOR   : If msg argument exists, it sets the status message body.
           Then it sets or updates the error number to MAJOR. Also
           it ends up printing the message body.
 CRITICAL: If msg argument exists, it sets the status message body.
           Then it prints the status message body along with the
           system error message as the argument. It then causes
           the program to exit immediately with the system error
           number.

Parameters:
levelSet or update priority level of error message
msgMain message of error (default: previous message)
argMessage argument of error (default: no argument)
outostream to output onto (default: global variable eout)

void  operator() (const ErrLevel& level, const string msg, const unsigned char& arg, ostream& out = *eout)

Same as above but handles an unsigned character for the argument

void  operator() (const ErrLevel& level, const string msg, const char& arg, ostream& out = *eout)

Same as above but handles a character for the argument

void  operator() (const ErrLevel& level, const string msg, const unsigned int arg, ostream& out = *eout)

Same as above but handles an unsigned integer for the argument

void  operator() (const ErrLevel& level, const string msg, const int arg, ostream& out = *eout)

Same as above but handles an integer for the argument

void  operator() (const ErrLevel& level, const string msg, const unsigned long arg, ostream& out = *eout)

Same as above but handles an unsigned long for the argument

void  operator() (const ErrLevel& level, const string msg, const long arg, ostream& out = *eout)

Same as above but handles a long for the argument

void  operator() (const string msg, const long arg, ostream& out = *eout)

This overload operator is basically the same as the one above, except this one is geared more towards lazy people who do not need to specify priority levels of error messages. The error level will default to MAJOR which is usually the most used error type.

Parameters:
msgMain message of error
argMessage argument of error (default: no argument)
outostream to output onto (default: global variable eout)

void  operator() (const string msg, const unsigned long arg, ostream& out = *eout)

Same as above but handles an unsigned long for the argument

void  operator() (const string msg, const int arg, ostream& out = *eout)

Same as above but handles an integer for the argument

void  operator() (const string msg, const unsigned int arg, ostream& out = *eout)

Same as above but handles an unsigned integer for the argument

void  operator() (const string msg, const char& arg, ostream& out = *eout)

Same as above but handles a character for the argument

void  operator() (const string msg, const unsigned char& arg, ostream& out = *eout)

Same as above but handles an unsigned character for the argument

void  operator() (const string msg, const string arg = SM_NULL, ostream& out = *eout)

Same as above but handles character string for the argument.

void  setOutput (ostream& newout)

[static]

This method can be called either by an object or directly within the class by "Error::setOuput(ostream)". This powerful method changes the output ostream for all Error objects.

Parameters:
newoutNew ostream for all error message outputs

void  setHeader (const string newheader, const string newboarder = eboarder)

[static]

This method can be called either by an object or directly within the class by "Error::setHeader(header)". This powerful method changes the header and/or boarder for all Error objects.

Parameters:
newheaderNew header
newboarderNew header boarder

Reimplemented from StatusMsg.


Generated on Fri Mar 9 02:04:42 2001, using kdoc 2.0a43.