VoiceMan
Public Member Functions | List of all members
SystemException Class Reference

The exception class to handle system call errors. More...

Inheritance diagram for SystemException:
VoicemanException

Public Member Functions

int getCode () const
 Returns the error code. More...
 
std::string getComment () const
 returns the comment value More...
 
std::string getDescr () const
 Returns the string description of the error generated by operating system by error code. More...
 
std::string getMessage () const
 Generates error message by comment and error description. More...
 
void makeLogReport (int level) const
 Makes report to logging system. More...
 
 SystemException ()
 The default constructor. More...
 
 SystemException (const std::string &comment)
 The constructor with comment specification. More...
 
 SystemException (int code)
 The constructor with error code specification. More...
 
 SystemException (int code, const std::string &comment)
 The constructor with comment and error code specification. More...
 
virtual ~SystemException ()
 The destructor.
 
- Public Member Functions inherited from VoicemanException
 VoicemanException ()
 The default constructor.
 
virtual ~VoicemanException ()
 The destructor.
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]commentThe comment value
SystemException::SystemException ( int  code)
inline
Parameters
[in]codeThe error code value
SystemException::SystemException ( int  code,
const std::string &  comment 
)
inline
Parameters
[in]codeThe error code value
[in]commentThe comment value

Member Function Documentation

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.

Returns
The code of corresponding error
std::string SystemException::getComment ( ) const
inline

This method just returned the single-line comment specified at this exception object creation.

Returns
The single-line error comment
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.

Returns
The error description provided by operating system
std::string SystemException::getMessage ( ) const
inlinevirtual

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.

Returns
The complete information about an error

Implements VoicemanException.

void SystemException::makeLogReport ( int  level) const
inlinevirtual

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.

Parameters
levelThe level of error log report

Implements VoicemanException.