Example, catching format/2 complaining about a lack of arguments:
catch( format("Hello, ~w. Goodbye ~!\n",[world]), Xc, format("\n\nOh noes! Got Exception!", [Xc])).
Hello, world. Goodbye Oh noes! Got Exception! Xc = error(existence_error(format_character, !), context(format/2, _11988)).
Example for when you want to call
main of your source file immediately after it has been loaded (from swipl-
:- initialization ( catch(main, E, ( print_message(error, E), fail )) -> halt ; halt(1) ).