AsmGrader 0.0.0
Loading...
Searching...
No Matches
error_types.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <boost/preprocessor/cat.hpp>
7
8namespace asmgrader {
9
10// NOLINTNEXTLINE
11enum class ErrorKind {
12 TimedOut,
18
20
21 MaxErrorNum // Not a proper error; used to determine the number of errors
22};
23
24template <typename T>
26
27} // namespace asmgrader
28
29FMT_SERIALIZE_ENUM(::asmgrader::ErrorKind, TimedOut, UnresolvedSymbol, UnexpectedReturn, BadArgument, SyscallPredSat,
30 UnknownError, SyscallFailure, MaxErrorNum);
31
34// NOLINTBEGIN(bugprone-macro-parentheses)
35#define TRYE_IMPL(val, e, ident) \
36 __extension__({ \
37 const auto& ident = val; \
38 if (!ident.has_value()) { \
39 using enum ErrorKind; \
40 return e; \
41 } \
42 ident.value(); \
43 })
44
45#define TRY_IMPL(val, ident) TRYE_IMPL(val, ident.error(), ident)
46// NOLINTEND(bugprone-macro-parentheses)
47
48#define TRYE(val, e) TRYE_IMPL(val, e, BOOST_PP_CAT(errref_uniq__, __COUNTER__))
49
52#define TRY(val) TRY_IMPL(val, BOOST_PP_CAT(errrefe_uniq__, __COUNTER__))
std::variant wrapper for a partial implementation of C++23's expected type
Definition expected.hpp:34
#define FMT_SERIALIZE_ENUM(enum_name,...)
Definition macros.hpp:40
Definition asm_buffer.hpp:20
ErrorKind
Definition error_types.hpp:11
@ UnexpectedReturn
A function returned happened due to an unexpected condition.
@ UnresolvedSymbol
Failed to resolve a named symbol in a program.
@ SyscallPredSat
The syscall predicate passed to Tracer::run_until was satisfied.
@ TimedOut
Program / operation surpassed maximum timeout (gennerally specified)
@ UnknownError
As named; use this as little as possible.
@ SyscallFailure
A Linux syscall failed.
@ BadArgument
Bad argument to an AsmFunction. For an unwrappable type with no inner value.