| Did you know ... | Search Documentation: |
| PlException class hierarchy |
PlException, there are convenience functions that create
and wrap a Prolog term, similar to the PL_domain_error(), etc.
The hierarchy allows catch statements to easily handle
combinations.
A PlException object contains a Prolog term, so its
what() method must be called either
within a Prolog predicate or within the context of a PlEngine
(and PlFrame; see section
1.16). The term is copied so that it is available outside of the
context of the frame that created it.
std::exception
*-- PlExceptionBase
*-- PlException
| *.. PlDomainError()
| *.. PlExistenceError()
| *.. PlGeneralError()
| *.. PlInstantiationError()
| *.. PlPermissionError()
| *.. PlRepresentationError()
| *.. PlResourceError()
| *.. PlTypeError()
| *.. PlUninstantiationError()
| *.. PlUnknownError()
*-- PlExceptionFailBase
| *-- PlExceptionFail
| *-- PlFail
*-- PlEngineInitialisationFailed
*-- PlOpenForeignFrameFailed
Note that everything under PlException can contain a
Prolog term; if the what() method is
called, it must be within the context of a Prolog frame. If you wish to
pass the exception outside the frame, you can use the set_what_str()
method to avoid evaluating the term after it has been freed by Prolog:
try
{ PlCall("p(123)");
...
} catch ( PlException &ex )
{ ex.set_what_str();
throw; // rethrow the exception
}
Currently defined methods are:
...;
try
{ PlCall("consult(load)");
} catch ( const PlException& ex )
{ cerr << ex.as_string() << endl;
}