stdex
Additional custom or not Standard C++ covered algorithms
Loading...
Searching...
No Matches
errno.hpp
1/*
2 SPDX-License-Identifier: MIT
3 Copyright © 2023 Amebis
4*/
5
6#pragma once
7
8#include "compat.hpp"
9#include <stdexcept>
10#include <cstring>
11
12namespace stdex
13{
17 class errno_error : public std::runtime_error
18 {
19 public:
26 errno_error(_In_ errno_t num, _In_ const std::string& msg) :
27 m_num(num),
28 runtime_error(msg)
29 {
30 }
31
38 errno_error(_In_ errno_t num, _In_opt_z_ const char *msg = nullptr) :
39 m_num(num),
40 runtime_error(msg)
41 {
42 }
43
49 errno_error(_In_ const std::string& msg) :
50 m_num(errno),
51 runtime_error(msg)
52 {
53 }
54
60 errno_error(_In_opt_z_ const char *msg = nullptr) :
61 m_num(errno),
62 runtime_error(msg)
63 {
64 }
65
69 errno_t number() const
70 {
71 return m_num;
72 }
73
74 protected:
75 errno_t m_num;
76 };
77}
Standard C runtime library error.
Definition errno.hpp:18
errno_t m_num
Numeric error code.
Definition errno.hpp:75
errno_error(errno_t num, const std::string &msg)
Constructs an exception.
Definition errno.hpp:26
errno_t number() const
Returns the error number.
Definition errno.hpp:69
errno_error(const std::string &msg)
Constructs an exception using GetLastError()
Definition errno.hpp:49
errno_error(const char *msg=nullptr)
Constructs an exception using GetLastError()
Definition errno.hpp:60
errno_error(errno_t num, const char *msg=nullptr)
Constructs an exception.
Definition errno.hpp:38