AsmGrader 0.0.0
Loading...
Searching...
No Matches
error_types.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <boost/describe/enum.hpp>
6#include <boost/preprocessor/cat.hpp>
7
8namespace asmgrader {
9
10// NOLINTNEXTLINE
12 TimedOut, // Program / operation surpassed maximum timeout (gennerally specified)
13 UnresolvedSymbol, // Failed to resolve a named symbol in a program
14 UnexpectedReturn, // A function returned happened due to an unexpected condition
15 UnknownError, // As named; use this as little as possible
16 SyscallFailure, // A Linux syscall failed
17
18 MaxErrorNum // Not a proper error; used to determine the number of errors
19);
20
21template <typename T>
23
24} // namespace asmgrader
25
28// NOLINTBEGIN(bugprone-macro-parentheses)
29#define TRYE_IMPL(val, e, ident) \
30 __extension__({ \
31 const auto& ident = val; \
32 if (!ident.has_value()) { \
33 using enum ErrorKind; \
34 return e; \
35 } \
36 ident.value(); \
37 })
38
39#define TRY_IMPL(val, ident) TRYE_IMPL(val, ident.error(), ident)
40// NOLINTEND(bugprone-macro-parentheses)
41
42#define TRYE(val, e) TRYE_IMPL(val, e, BOOST_PP_CAT(errref_uniq__, __COUNTER__))
43
46#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
Definition asm_buffer.hpp:19
BOOST_DEFINE_ENUM_CLASS(ErrorKind, TimedOut, UnresolvedSymbol, UnexpectedReturn, UnknownError, SyscallFailure, MaxErrorNum)