SWI-Prolog defines the predicates catch3 and throw1 for ISO compliant raising and catching of exceptions. In the current implementation (2.9.0), only part of the built-in predicates generate exceptions. In general, exceptions are implemented for I/O and arithmetic.
The overhead of calling a goal through catch3 is very comparable to call1. Recovery from an exception has a similar overhead. throw1+Exception Raise an exception. The system will look for the innermost catch3 ancestor for which Exception unifies with the Catcher argument of the catch3 call. See catch3 for details.
If there is no catch3 willing to catch the error in the current Prolog context, the toplevel (prolog0) catches the error and prints a warning message. If an exception was raised in a callback from C (see foreign), PL_next_solution will fail and the exception context can be retrieved using PL_exception.