• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

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)
Sourcecatch(:Goal, +ExceptionType, ?Ball, :Recover)
As catch/3, only catching exceptions for which exception(ErrorType,Ball) is true. See error/2. For example, the code below properly informs the user some file could not be processed due do some issue with File, while propagating on all other reasons while process/1 could not be executed.
    catch(process(File), file_error, Ball,
          file_not_processed(File, Ball))

file_not_processed(File, Ball) :-
    message_to_string(Ball, Msg),
    format(user_error, 'Could not process ~p: ~s', [File, Msg]).
ClioPatria (version V3.1.1-51-ga0b30a5)