SymEngine Exceptions
SymEngine uses SymEngineException
as the base type for exceptions arising from various SymEngine functions.
All exceptions derived from SymEngineException
must contain symengine_exceptions_t error_code()
which returns one of the error codes from the enum symengine_exceptions_t
.
In the symengine_exceptions_t
enum, 0
means no exception and 1
means a generic SymEngineException
. Add other exception values as necessary.
In the C wrappers, all methods will return a CWRAPPER_OUTPUT_TYPE
(which is the same as symengine_exceptions_t
) and the functional code should be sandwiched between the macros CWRAPPER_BEGIN
and CWRAPPER_END
to accommodate exception handling.
In the other language wrappers, proper exception handling should be performed according to the language by examining the error code returned by the C wrapper. For an example, in the Ruby wrapper, the void raise_exception(symengine_exceptions_t error_code)
is called with the returned error code.