Sese Framework
x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
Exception.h
浏览该文件的文档.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
22
#pragma once
23
24
#include <
sese/Config.h
>
25
#include <
sese/io/OutputStream.h
>
26
#include <
sese/record/Logger.h
>
27
#include <
sese/system/StackInfo.h
>
28
29
#include <exception>
30
#include <utility>
31
32
#ifdef SESE_PLATFORM_WINDOWS
33
#pragma warning(disable : 4275)
34
#endif
35
36
namespace
sese
{
37
38
#if defined(_MSC_VER)
39
using
NativeException
= std::exception;
40
#else
42
class
UnixException
:
public
std::exception {
43
public
:
44
explicit
UnixException
(
const
char
*message) : std::exception(),
msg
(message) {
45
}
46
47
[[nodiscard]]
const
char
*
what
() const noexcept
override
{
48
return
msg
;
49
}
50
51
private
:
52
const
char
*
msg
{};
53
};
54
55
using
NativeException
=
UnixException
;
56
#endif
57
59
class
Exception
:
public
NativeException
{
60
public
:
61
explicit
Exception
(std::string
message
);
62
63
~Exception
()
override
;
64
66
void
printStacktrace
();
67
70
void
printStacktrace
(
sese::record::Logger
*logger);
71
74
void
printStacktrace
(
sese::io::OutputStream
*output);
75
76
static
uint16_t
offset
;
77
80
[[nodiscard]]
const
char
*
what
() const noexcept override;
81
84
[[nodiscard]] std::
string
message
() const noexcept;
85
86
protected:
87
virtual std::
string
buildStacktrace
();
88
89
std::
string
*
message_
;
90
system::StackInfo*
stackInfo
{};
91
};
92
}
// namespace sese
sese
util
Exception.h
生成于 2024年 十一月 4日 星期一 09:58:03 , 为 Sese Framework使用
1.11.0