Dv::Util::SystemError Class Reference

Exception class associated with a system error. More...

#include <systemerror.h>

List of all members.

Public Member Functions

 SystemError (int error_code=0)
 Construct new runtime_error exception.
 SystemError (const std::string &message, int error_code=0)
 Construct new runtime_error exception.
int err_no () const

Static Public Member Functions

static std::string strerror (int err=0)

Private Attributes

int errno_

Detailed Description

Exception class associated with a system error.

Derived from runtime_error.

Example:

 if (fork() == -1)
   throw SystemError();
 if (execl(..) == -1)
    throw SystemError("execl failed");   
 if (kill(..,..) == -1) {
   int e = errno;
   throw SystemError(e);
   }

Definition at line 27 of file systemerror.h.


Constructor & Destructor Documentation

Dv::Util::SystemError::SystemError ( int  error_code = 0  ) 

Construct new runtime_error exception.

this->what() will contain NAME + error_code + system error message obtained using strerror(error_code)

Parameters:
error_code system error code, should be valid input for strerror. If 0, the global :errno will be used instead.
Dv::Util::SystemError::SystemError ( const std::string &  message,
int  error_code = 0 
)

Construct new runtime_error exception.

this->what() will contain message + error_code + system error message obtained using strerror(error_code)

Parameters:
message will be used instead of NAME (see above)
error_code system error code, should be valid input for strerror. If 0, the global :errno will be used instead.

Member Function Documentation

int Dv::Util::SystemError::err_no (  )  const [inline]
Returns:
error code of this SystemError
Warning:
This function is not called errno() because <string.h> defines errno as a macro.

Definition at line 56 of file systemerror.h.

References errno_.

static std::string Dv::Util::SystemError::strerror ( int  err = 0  )  [static]

Member Data Documentation

Definition at line 59 of file systemerror.h.

Referenced by err_no().


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

dvutil-1.0.10 [ 5 December, 2009]