alpaqa develop
Nonconvex constrained optimization
Loading...
Searching...
No Matches
cutest-errors.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <stdexcept>
4
5namespace alpaqa::cutest {
6
7enum class Status {
8 Success = 0, ///< Successful call.
9 AllocErr = 1, ///< Array allocation/deallocation error.
10 BoundErr = 2, ///< Array bound error.
11 EvalErr = 3, ///< Evaluation error.
12};
13
14inline constexpr const char *enum_name(Status s) {
15 switch (s) {
16 case Status::Success: return "Success";
17 case Status::AllocErr: return "AllocErr";
18 case Status::BoundErr: return "BoundErr";
19 case Status::EvalErr: return "EvalErr";
20 default:;
21 }
22 return "<unknown>";
23}
24
25struct function_call_error : std::runtime_error {
26 function_call_error(std::string message, Status status)
27 : runtime_error{std::move(message) + ": " + enum_name(status) + " (" +
28 std::to_string(static_cast<int>(status)) + ')'},
29 status{status} {}
31};
32
33} // namespace alpaqa::cutest
@ AllocErr
Array allocation/deallocation error.
@ BoundErr
Array bound error.
@ Success
Successful call.
@ EvalErr
Evaluation error.
constexpr doublereal inf
constexpr const char * enum_name(Status s)
function_call_error(std::string message, Status status)