Echo Writes Code

windows_error.inl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef CRUCIBLE_WINDOWS_WINDOWS_ERROR_INL
#define CRUCIBLE_WINDOWS_WINDOWS_ERROR_INL

#include "crucible/windows/windows_error.hpp"

#include <sstream>

namespace crucible::windows::windows_error {
  template<typename DERIVED>
  WindowsError<DERIVED>::WindowsError() :
    my_error_code(get_windows_error_code()) {
  }

  template<typename DERIVED>
  auto WindowsError<DERIVED>::format() const -> std::string {
    std::ostringstream buffer;
    buffer << DERIVED::function << "() failed: " << format_windows_error_code(my_error_code);
    return buffer.str();
  }
}

#endif // CRUCIBLE_WINDOWS_WINDOWS_ERROR_INL