AsmGrader 0.0.0
Loading...
Searching...
No Matches
exceptions.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <fmt/base.h>
7#include <fmt/format.h>
8
9#include <stdexcept>
10#include <string>
11
12namespace asmgrader {
13
15class ContextInternalError : public std::runtime_error
16{
17public:
18 using std::runtime_error::runtime_error;
19
20 explicit ContextInternalError(ErrorKind error, const std::string& msg = "")
21 : std::runtime_error{msg}
22 , error_{error} {}
23
24 ErrorKind get_error() const { return error_; };
25
26private:
27 ErrorKind error_ = ErrorKind::UnknownError;
28};
29
30} // namespace asmgrader
31
32template <>
34{
35 auto format(const ::asmgrader::ContextInternalError& from, format_context& ctx) const {
36 return format_to(ctx.out(), "{} : {}", from.what(), fmt::underlying(from.get_error()));
37 }
38};
Error for any internal failure conditions of TestContext.
Definition exceptions.hpp:16
ContextInternalError(ErrorKind error, const std::string &msg="")
Definition exceptions.hpp:20
ErrorKind get_error() const
Definition exceptions.hpp:24
Definition asm_buffer.hpp:19
Definition debug.hpp:9
auto format(const ::asmgrader::ContextInternalError &from, format_context &ctx) const
Definition exceptions.hpp:35