Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
try_catch_shim.hpp
Go to the documentation of this file.
1#pragma once
3#include <string>
4
5// Tool to make header only libraries (i.e. CLI11 and msgpack, though it has a bundled copy)
6// not use exceptions with minimally invaslive changes.
7//
8// Macros are guarded so any parent project (e.g. ipc_codegen/throw.hpp under
9// codegen-emitted code) that predefines them wins. Same convention as
10// ipc_codegen/throw.hpp, so the two headers can be #included in any order
11// without redefinition warnings.
12
13#ifndef THROW
14
15#ifdef BB_NO_EXCEPTIONS
16struct __AbortStream {
17 void operator<< [[noreturn]] (const auto& error)
18 {
19 info(error.what());
20 std::abort();
21 }
22};
23#define THROW __AbortStream() <<
24#define try if (true)
25#define catch(...) if (false)
26#define RETHROW
27#else
28#define THROW throw
29#define RETHROW THROW
30#endif
31
32#endif // THROW
#define info(...)
Definition log.hpp:93