A.17 library(exceptions): Exception classification
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(exceptions): Exception classification
          • catch/4
          • exception/2
          • error_term/2
          • exception_term/2
          • exception_type/2
    • Packages
Availability::- use_module(library(exceptions)).(can be autoloaded)
Source[det]exception(:Type, --Ball)
[semidet]exception(:Type, +Ball)
If Ball is unbound, adds a delayed goal that tests the error belongs to Type when Ball is instantiated (by catch/3). Else succeed is error is of the specified Type.

Note that the delayed goal is added using freeze/2 and therefore the stepwise instantiation of Ball does not work, e.g. exception(file_error, error(Formal,_)) immediately fails.

Error types may be defined or extended (e.g., by libraries) by adding clauses to the multifile predicates error_term/2 and exception_term/2. Modules may (re-)define local error types using the exception_type/2 directive.