Macaulay2 Engine
Loading...
Searching...
No Matches
exceptions.hpp File Reference

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

Detailed Description

namespace exc — internal C++ exception types and the TRY / CATCH macro pair.

Note
AI-generated documentation. Verify against the source before relying on it.

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.

See also
error.h
overflow.hpp

Definition in file exceptions.hpp.