FRI-OS
error.hpp
Go to the documentation of this file.
1 
4 #ifndef __FRIOS_POSIX_ERROR_HPP__
5 #define __FRIOS_POSIX_ERROR_HPP__
6 
7 #include <stdexcept>
8 #include <cstring>
9 
10 namespace frios {
11 namespace posix {
12 
14 class error
15  : public std::runtime_error
16 {
17 private:
18  static std::string _fmt_msg(int error_code)
19  {
20  const std::size_t size = 1023;
21  char buffer[size+1];
22  return std::string(strerror_r(error_code, buffer, size));
23  }
24 public:
26  error(int error_code)
27  : std::runtime_error(_fmt_msg(error_code))
28  { }
29 };
30 
31 } // namespace posix
32 } // namespace frios
33 
34 #endif // include guard
Base class for all POSIX exceptions.
Definition: error.hpp:14
error(int error_code)
Construction from POSIX error code.
Definition: error.hpp:26