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

2.9 The class PlFail (version 2)
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • A C++ interface to SWI-Prolog
        • A C++ interface to SWI-Prolog (Version 2)
          • The class PlFail (version 2)
            • PlCheckFail(), PlCheckEx(), and PlCheck_PL() convenience functions

2.9.1 PlCheckFail(), PlCheckEx(), and PlCheck_PL() convenience functions

If one of the C "PL_" functions in SWI-Prolog.h returns failure, this can be either a Prolog-style failure (e.g. from PL_unify() or PL_next_solution()) or an error. If the failure is due to an error, it's usually best to immediately return to Prolog - and this can be done with the PlCheckEx() function, which turns a Prolog error into a C++ PlException. PlCheckFail() calls PlCheckEx() and additionally throws PlFail() if the failure is for Prolog failure.

The code for PlCheck() is just

void PlCheck(int rc)
{ if ( !PlCheckEx(rc) ) throw PlFail(); }

PlCheckEx() calls PL_exception() to see if there is a Prolog exception; if so, the Prolog exception is converted to a PlException object, which is then thrown. For more details on the C++ exceptions, see section 2.18.

ClioPatria (version V3.1.1-48-gf653ce4)