12.4.15 Prolog exceptions in foreign code
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • The Foreign Include File
          • Prolog exceptions in foreign code
            • PL_raise_exception()
            • PL_throw()
            • PL_exception()
            • PL_clear_exception()
    • Packages
Availability:C-language interface function
term_t PL_exception(qid_t qid)
If PL_next_solution() fails, this can be due to normal failure of the Prolog call, or because an exception was raised using throw/1. This function returns a handle to the exception term if an exception was raised, or (term_t)0 if the Prolog goal simply failed. If there is an exception, PL_exception() returns a term reference that contains the exception term.

Additionally, PL_exception(0) returns the pending exception in the current query or (term_t)0 if no exception is pending. This can be used to check the error status after a failing call to, e.g., one of the unification functions.