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// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_EXCEPTION_RAISE_HPP
5#define TETL_EXCEPTION_RAISE_HPP
6
7#include <etl/_config/all.hpp>
8
9#include <etl/_cassert/assert.hpp>
10#include <etl/_exception/exception.hpp>
11#include <etl/_source_location/source_location.hpp>
12
13namespace etl {
14
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
23 etl::assert_handler(
24 etl::assert_msg{
25 static_cast<int>(loc.line()),
26 loc.file_name(),
27 loc.function_name(),
28 Exception{msg}.what(),
29 }
30 );
31#endif
32}
33
34} // namespace etl
35
36#endif // TETL_EXCEPTION_RAISE_HPP
Definition adjacent_find.hpp:9
TETL_NO_INLINE TETL_COLD auto raise(char const *msg, etl::source_location const loc=etl::source_location::current()) -> void
Definition raise.hpp:17
A class representing information about the source code, such as file names, line numbers,...
Definition source_location.hpp:20
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:21