aligator 0.19.0
A versatile and efficient C++ library for real-time constrained trajectory optimization.
Loading...
Searching...
No Matches
exceptions.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <stdexcept>
4#include <string>
5#include <fmt/core.h>
6#include <fmt/format.h>
7
8#define ALIGATOR_RUNTIME_ERROR(...) \
9 throw ::aligator::RuntimeError( \
10 ::aligator::detail::exception_msg(__FILE__, __LINE__, __VA_ARGS__))
11
12#define ALIGATOR_OUT_OF_RANGE_ERROR(...) \
13 throw ::std::out_of_range( \
14 ::aligator::detail::exception_msg(__FILE__, __LINE__, __VA_ARGS__))
15
16#define ALIGATOR_DOMAIN_ERROR(...) \
17 throw ::std::domain_error( \
18 ::aligator::detail::exception_msg(__FILE__, __LINE__, __VA_ARGS__))
19
20#define ALIGATOR_WARNING(loc, ...) \
21 ::aligator::detail::warning_call(loc, __FUNCTION__, __VA_ARGS__)
22
23namespace aligator {
24namespace detail {
25void warning_impl(const char *loc, const char *fun, fmt::string_view fstr,
26 fmt::format_args args);
27template <typename... T>
28void warning_call(const char *loc, const char *fun,
29 fmt::format_string<T...> fstr, T &&...args) {
30 warning_impl(loc, fun, fstr, fmt::make_format_args(args...));
31}
32template <typename T>
33void warning_call(const char *loc, const char *fun, T &&msg) {
34 warning_impl(loc, fun, msg, {});
35}
36
37std::string exception_msg_impl(const char *filename, int lineno,
38 fmt::string_view fstr, fmt::format_args args);
39template <typename... T>
40std::string exception_msg(const char *filename, int lineno,
41 fmt::format_string<T...> fstr, T &&...args) {
42 return exception_msg_impl(filename, lineno, fstr,
43 fmt::make_format_args(args...));
44}
45} // namespace detail
46
47class RuntimeError : public std::runtime_error {
48public:
49 explicit RuntimeError(const std::string &what)
50 : std::runtime_error(what) {}
51};
52
53} // namespace aligator
RuntimeError(const std::string &what)
Main package namespace.