VoiceMan
|
The exception class to handle system call errors. More...
Public Member Functions | |
int | getCode () const |
Returns the error code. | |
std::string | getComment () const |
returns the comment value | |
std::string | getDescr () const |
Returns the string description of the error generated by operating system by error code. | |
std::string | getMessage () const |
Generates error message by comment and error description. | |
void | makeLogReport (int level) const |
Makes report to logging system. | |
SystemException () | |
The default constructor. | |
SystemException (const std::string &comment) | |
The constructor with comment specification. | |
SystemException (int code) | |
The constructor with error code specification. | |
SystemException (int code, const std::string &comment) | |
The constructor with comment and error code specification. | |
virtual | ~SystemException () |
The destructor. |
This exception class is designed for error handling based on analyzing value of UNIX errno variable. The corresponding value is set to this variable in case of errors in all system calls. Also this class has one single-line description used to provide name of system call caused the problem or something else like file name in case of file I/O operations.
SystemException::SystemException | ( | ) | [inline] |
This constructor gets error code automatically by using errno variable and leavs comment string empty.
SystemException::SystemException | ( | const std::string & | comment | ) | [inline] |
This constructor takes comment value as string argument and gets error code by using errno variable.
[in] | comment | The comment value |
SystemException::SystemException | ( | int | code | ) | [inline] |
[in] | code | The error code value |
SystemException::SystemException | ( | int | code, |
const std::string & | comment | ||
) | [inline] |
[in] | code | The error code value |
[in] | comment | The comment value |
int SystemException::getCode | ( | ) | const [inline] |
The error code returned by this method usually the errno value of the corresponding system call error but in general case it can be anything else, because user can set any desired value in exception constructor.
std::string SystemException::getComment | ( | ) | const [inline] |
This method just returned the single-line comment specified at this exception object creation.
std::string SystemException::getDescr | ( | ) | const [inline] |
This method uses strerror() function to get error description provided by operating system itself. This string must not be confused with the value returned by getComment() method which is just single-line comment specified in exception object construction.
std::string SystemException::getMessage | ( | ) | const [inline, virtual] |
This method generates single-line error description which user can print to console or write to log. This description aims to have complete information about error occurred. Usually it includes both descriptions from operating system and specified at exception object creation.
Implements VoicemanException.
void SystemException::makeLogReport | ( | int | level | ) | const [inline, virtual] |
This function writes to log a report about error object. It may be not exactly the same value as produced by getMessage() method. The level of message must be specified, because the same error can have different levels in different situations.
level | The level of error log report |
Implements VoicemanException.