alpaqa 1.0.0a15
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
7struct function_load_error : std::runtime_error {
8 using std::runtime_error::runtime_error;
9};
10
11enum class Status {
12 Success = 0, ///< Successful call.
13 AllocErr = 1, ///< Array allocation/deallocation error.
14 BoundErr = 2, ///< Array bound error.
15 EvalErr = 3, ///< Evaluation error.
16};
17
18inline constexpr const char *enum_name(Status s) {
19 switch (s) {
20 case Status::Success: return "Success";
21 case Status::AllocErr: return "AllocErr";
22 case Status::BoundErr: return "BoundErr";
23 case Status::EvalErr: return "EvalErr";
24 default:;
25 }
26 return "<unknown>";
27}
28
29struct function_call_error : std::runtime_error {
30 function_call_error(std::string message, Status status)
31 : runtime_error{std::move(message) + ": " + enum_name(status) + " (" +
32 std::to_string(static_cast<int>(status)) + ')'},
33 status{status} {}
35};
36
37} // 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)