Kiwano Engine v1.3.x
Exception.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/core/Common.h>
23#include <stdexcept>
24#include <system_error>
25
26namespace kiwano
27{
28
31typedef std::exception Exception;
32
35typedef std::runtime_error RuntimeError;
36
39typedef std::system_error SystemError;
40
42{
43public:
45
46 void Print() const;
47};
48
49#ifdef KGE_PLATFORM_WINDOWS
50
51// Enables classifying error codes
52// @note We don't bother listing all possible values
53enum class error_enum
54{
55};
56
57#else
58
59typedef std::errc error_enum;
60
61#endif
62
63} // namespace kiwano
64
65#ifdef KGE_PLATFORM_WINDOWS
66
67namespace std
68{
69template <>
70struct is_error_code_enum<kiwano::error_enum> : true_type
71{
72};
73} // namespace std
74
75namespace kiwano
76{
77
78const std::error_category& com_category() noexcept;
79
80inline std::error_code make_error_code(kiwano::error_enum errc) noexcept
81{
82 return std::error_code(static_cast<int>(errc), kiwano::com_category());
83}
84
85inline std::error_condition make_error_condition(kiwano::error_enum errc) noexcept
86{
87 return std::error_condition(static_cast<int>(errc), kiwano::com_category());
88}
89
90} // namespace kiwano
91
92#endif // KGE_PLATFORM_WINDOWS
Definition: Exception.h:42