Sen API
Sen Libraries
Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
1// === assert.h ========================================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_CORE_BASE_ASSERT_H
9#define SEN_CORE_BASE_ASSERT_H
10
12
13// std
14#include <memory>
15#include <stdexcept>
16#include <string>
17
18namespace sen
19{
20
33
36
38#define SEN_EXPECT(expr) ::sen::impl::senCheckImpl((expr), ::sen::impl::CheckType::expect, #expr, SEN_SL())
39
41#define SEN_ASSERT(expr) ::sen::impl::senCheckImpl((expr), ::sen::impl::CheckType::assert, #expr, SEN_SL())
42
44#if defined(DEBUG)
45# define SEN_DEBUG_ASSERT(expr) ::sen::impl::senCheckImpl((expr), ::sen::impl::CheckType::assert, #expr, SEN_SL())
46#else
47# define SEN_DEBUG_ASSERT(expr)
48#endif
49
51#define SEN_ENSURE(expr) ::sen::impl::senCheckImpl((expr), ::sen::impl::CheckType::ensure, #expr, SEN_SL())
52
55
65class TracedRuntimeError: public std::runtime_error
66{
67public:
68 explicit TracedRuntimeError(const std::string& err);
69
71 [[nodiscard]] std::string getTrace(bool color = false) const;
72
73private:
74 std::shared_ptr<const void> trace_;
75};
76
78[[noreturn]] void throwRuntimeError(const std::string& err);
79
81void trace();
82
86void trace(std::string preMessage);
87
89
90} // namespace sen
91
92#endif // SEN_CORE_BASE_ASSERT_H
TracedRuntimeError(const std::string &err)
std::string getTrace(bool color=false) const
The throw site's trace, symbolised on each call.
void throwRuntimeError(const std::string &err)
Throws an exception that attempts to collect the stack trace.
void registerTerminateHandler()
Installs a custom termination handler.
void trace()
Prints the current stack trace to stderr.
Definition assert.h:19