errors 0.6.3
Loading...
Searching...
No Matches
system_error.hpp
1#pragma once
2
3#include <cassert>
4#include <cstring>
5#include <string>
6
7#include "errors/impl/code_error.hpp"
8
9namespace errors
10{
11namespace impl
12{
13
16class system_error : public code_error<int> {
17 public:
30 system_error(const std::string &message, int code,
32 : code_error(message + ": " + strerror(code), code,
33 std::move(location))
34 {
35 }
36
47 : code_error(strerror(code), code, std::move(location))
48 {
49 }
50
61 : code_error(message + ": " + strerror(errno), errno,
62 std::move(location))
63 {
64 }
65
73 : code_error(strerror(errno), errno, std::move(location))
74 {
75 }
76};
77
78static_assert(!std::is_abstract<code_error<unsigned int>>());
79}
80}
std::optional< source_location > location() const noexcept override
Get the source location of this error, if any.
Definition base_error.hpp:28
An error that has a code.
Definition code_error.hpp:24
int code
Definition code_error.hpp:52
std::string message
The error message.
Definition runtime_error.hpp:41
An error that has a system error code.
Definition system_error.hpp:16
system_error(const std::string &message, source_location location)
Create a system error from errno. The message will be pretended to the error message from strerror.
Definition system_error.hpp:60
system_error(const std::string &message, int code, source_location location)
Create a system error from a message and a code. The message will be pretended to the error message f...
Definition system_error.hpp:30
system_error(source_location location)
Create a system error from errno. The message will be set to the error message from strerror.
Definition system_error.hpp:72
system_error(int code, source_location location)
Create a system error from a code. The message will be set to the error message from strerror.
Definition system_error.hpp:46
The source location.
Definition source_location.hpp:46