Function swipl::context::prolog_catch_unwind
source · pub unsafe fn prolog_catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(
f: F
) -> PrologResult<R>
Expand description
Call the given function, converting panics into prolog exceptions.
If the inner function panics, an exception of the form
error(rust_error(panic("..the panic message..")))
will be
raised, and this function will return
Err(PrologError::Exception)
. Otherwise, This function will
return Ok(())
.
This is used by various macros to ensure that panics from user code do not propagate into prolog.
Safety
This is only safe to use from an environment from which we can raise a prolog exception.