-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.cppm
More file actions
33 lines (31 loc) · 1.06 KB
/
base.cppm
File metadata and controls
33 lines (31 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module;
#include <format>
#include <stdexcept>
#include <source_location>
#include <stacktrace>
export module base;
// Error Handling
export class LibraryException
: public std::runtime_error
{
public:
LibraryException() = delete;
LibraryException(const LibraryException&) = default;
LibraryException(LibraryException&&) noexcept = default;
auto operator=(const LibraryException&) -> LibraryException& = default;
auto operator=(LibraryException&&) noexcept -> LibraryException& = default;
virtual ~LibraryException() = default;
explicit LibraryException(
std::string const& message = "",
std::source_location const& source_location = std::source_location::current(),
std::stacktrace const& stacktrace = std::stacktrace::current()
) noexcept
: std::runtime_error(std::format(
"source_location: {}({}:{}) `{}`: {}\n"
"stacktrace: {}",
source_location.file_name(), source_location.line(), source_location.column(), source_location.function_name(), message,
stacktrace
))
{}
using std::runtime_error::what;
};