|
Macaulay2 Engine
|
namespace exc — internal C++ exception types and the TRY / CATCH macro pair. More...
#include <stdexcept>#include <string>Go to the source code of this file.
Classes | |
| struct | exc::engine_error |
| struct | exc::overflow_exception |
| struct | exc::division_by_zero_error |
| struct | exc::internal_error |
Namespaces | |
| namespace | exc |
Macros | |
| #define | TRY |
| #define | CATCH |
namespace exc — internal C++ exception types and the TRY / CATCH macro pair.
Declares a small hierarchy rooted at std::runtime_error: engine_error (the base catch-all), overflow_exception (arithmetic overflow, thrown by overflow.hpp), division_by_zero_error (with both a (const std::string&) constructor and a zero-arg fallback that fills in the fixed message "division by zero"), and internal_error (invariant violation that should not be reachable). These exist so templated engine code can unwind cleanly through arbitrary call depth without checking an error return after every operation. The companion TRY / CATCH macros at the bottom standardise the boundary translation: the CATCH block catches const exc::engine_error&, routes its what() into ERROR(...) from error.h, and return NULLs — so the message reaches the interpreter via the file- static error slot in error.c.
C++ exceptions must not propagate to the interpreter (the .d-generated C glue cannot unwind C++ stacks), so every entry point from the interpreter side either runs inside TRY/CATCH or is responsible for translating manually. Concrete arings, overflow checks, and engine invariant assertions are the main sources of throws.
Definition in file exceptions.hpp.