Program Listing for File posix_error_handler.hpp
↰ Return to documentation for file (include/ecl/exceptions/posix_error_handler.hpp
)
/*****************************************************************************
** Ifdefs
*****************************************************************************/
#ifndef ECL_EXCEPTIONS_POSIX_EXCEPTION_HPP_
#define ECL_EXCEPTIONS_POSIX_EXCEPTION_HPP_
/*****************************************************************************
** Disable check
*****************************************************************************/
#include <ecl/config/ecl.hpp>
#ifndef ECL_DISABLE_EXCEPTIONS
/*****************************************************************************
** Includes
*****************************************************************************/
#include <cstring> // strerror function
#include <string>
#include <errno.h>
#include "standard_exception.hpp"
/*****************************************************************************
** Namespaces
*****************************************************************************/
namespace ecl {
/*****************************************************************************
** Interface [PosixErrorHandler]
*****************************************************************************/
template <typename ThrowingClass>
class ecl_exceptions_PUBLIC PosixErrorHandler {
public:
static StandardException GenerateStandardException(const char* loc) {
return StandardException(loc, PosixError, std::string(strerror(errno))+".");
}
virtual ~PosixErrorHandler() {}
};
} // namespace ecl
#endif /* ECL_DISABLE_EXCEPTIONS */
#endif /* ECL_EXCEPTIONS_POSIX_EXCEPTION_HPP_ */