aligator  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear 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
7#define ALIGATOR_RUNTIME_ERROR(...) \
8 throw ::aligator::RuntimeError( \
9 ::aligator::detail::exception_msg(__FILE__, __LINE__, __VA_ARGS__))
10
11#define ALIGATOR_DOMAIN_ERROR(msg) \
12 throw std::domain_error( \
13 ::aligator::detail::exception_msg(__FILE__, __LINE__, msg))
14
15#define ALIGATOR_WARNING(loc, ...) \
16 ::aligator::detail::warning_call(loc, __FUNCTION__, __VA_ARGS__)
17
18namespace aligator {
19namespace detail {
20void warning_impl(const char *loc, const char *fun, fmt::string_view fstr,
21 fmt::format_args args);
22template <typename... T>
23void warning_call(const char *loc, const char *fun,
24 fmt::format_string<T...> fstr, T &&...args) {
25 warning_impl(loc, fun, fstr, fmt::make_format_args(args...));
26}
27template <typename T>
28void warning_call(const char *loc, const char *fun, T &&msg) {
29 warning_impl(loc, fun, msg, {});
30}
31
32std::string exception_msg_impl(const char *filename, int lineno,
33 fmt::string_view fstr, fmt::format_args args);
34template <typename... T>
35std::string exception_msg(const char *filename, int lineno,
36 fmt::format_string<T...> fstr, T &&...args) {
37 return exception_msg_impl(filename, lineno, fstr,
38 fmt::make_format_args(args...));
39}
40} // namespace detail
41
42class RuntimeError : public std::runtime_error {
43public:
44 explicit RuntimeError(const std::string &what) : std::runtime_error(what) {}
45};
46
47} // namespace aligator
RuntimeError(const std::string &what)
std::string exception_msg_impl(const char *filename, int lineno, fmt::string_view fstr, fmt::format_args args)
std::string exception_msg(const char *filename, int lineno, fmt::format_string< T... > fstr, T &&...args)
void warning_impl(const char *loc, const char *fun, fmt::string_view fstr, fmt::format_args args)
void warning_call(const char *loc, const char *fun, fmt::format_string< T... > fstr, T &&...args)
Main package namespace.