• 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

1.15 Exceptions
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • A C++ interface to SWI-Prolog
        • A C++ interface to SWI-Prolog
          • Exceptions
            • The class PlException
              • The function PlTypeError
              • The function PlDomainError

1.15.1 The class PlException

This subclass of PlExceptionBase is used to represent exceptions. Currently defined methods are:

PlException :: PlException(const PlTerm &)
Create an exception from a general Prolog term. This provides the interface for throwing any Prolog terms as an exception.
std::string as_string()
The exception is translated into a message as produced by print_message/2. The character data is stored in a ring. Example:
  ...;
  try
  { PlCall("consult(load)");
  } catch ( PlException& ex )
  { cerr << ex.as_string() << endl;
  }
int plThrow()
Used in the PREDICATE() wrapper to pass the exception to Prolog. See PL_raise_exeption().

1.15.1.1 The function PlTypeError

A type error expresses that a term does not satisfy the expected basic Prolog type.

PlTypeError :: PlTypeError(const std::string& expected, const PlTerm &actual)
Creates an ISO standard Prolog error term expressing the expected type and actual term that does not satisfy this type.

1.15.1.2 The function PlDomainError

A domain error expresses that a term satisfies the basic Prolog type expected, but is unacceptable to the restricted domain expected by some operation. For example, the standard Prolog open/3 call expect an io_mode (read, write, append, ...). If an integer is provided, this is a type error, if an atom other than one of the defined io-modes is provided it is a domain error.

PlDomainError :: PlDomainError(const std::string& expected, const PlTerm &actual)
Creates an ISO standard Prolog error term expressing a the expected domain and the actual term found.

ClioPatria (version V3.1.1-51-ga0b30a5)