tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
raise.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_EXCEPTION_RAISE_HPP
4#define TETL_EXCEPTION_RAISE_HPP
5
6#include <etl/_config/all.hpp>
7
11
12namespace etl {
13
14#if defined(__cpp_consteval)
15template <typename Exception>
16[[noreturn]] TETL_NO_INLINE TETL_COLD auto
17raise(char const* msg, etl::source_location const loc = etl::source_location::current()) -> void
18{
19 #if defined(TETL_ENABLE_CUSTOM_EXCEPTION_HANDLER)
20 (void)loc;
21 etl::exception_handler(Exception{msg});
22 #else
24 static_cast<int>(loc.line()),
25 loc.file_name(),
26 loc.function_name(),
27 Exception{msg}.what(),
28 });
29 #endif
30}
31
32#else
33
34template <typename Exception>
35[[noreturn]] TETL_NO_INLINE TETL_COLD auto raise(char const* msg) -> void
36{
37 #if defined(TETL_ENABLE_CUSTOM_EXCEPTION_HANDLER)
38 etl::exception_handler(Exception{msg});
39 #else
40 etl::assert_handler(etl::assert_msg{
41 0,
42 nullptr,
43 nullptr,
44 Exception{msg}.what(),
45 });
46 #endif
47}
48#endif
49} // namespace etl
50
51#endif // TETL_EXCEPTION_RAISE_HPP
#define TETL_NO_INLINE
Definition attributes.hpp:19
#define TETL_COLD
Definition attributes.hpp:25
Definition adjacent_find.hpp:8
TETL_NO_INLINE TETL_COLD auto raise(char const *msg, etl::source_location const loc=etl::source_location::current()) -> void
Definition raise.hpp:17
auto assert_handler(Assertion const &msg) -> void
Definition assert.hpp:39
Payload for an assertion.
Definition assert.hpp:21
A class representing information about the source code, such as file names, line numbers,...
Definition source_location.hpp:21
static consteval auto current(uint_least32_t const line=TETL_BUILTIN_LINE(), uint_least32_t const column=TETL_BUILTIN_COLUMN(), char const *const file=TETL_BUILTIN_FILE(), char const *const function=TETL_BUILTIN_FUNCTION()) noexcept -> source_location
Definition source_location.hpp:22