shithub: pprolog

Download patch

ref: 855fd0a5eacdc52699e3e187fcde1a4895ca5f6a
parent: e5ab41faf611c61878ad792cbaaf0294cd5715dd
author: Peter Mikkelsen <peter@pmikkelsen.com>
date: Thu Jul 1 16:39:58 EDT 2021

Add standard error predicates

--- a/stdlib.pl
+++ b/stdlib.pl
@@ -68,3 +68,32 @@
 member(X, [X|_]).
 member(X, [_|Tail]) :-
 	member(X, Tail).
+
+% Standard exceptions
+
+instantiation_error :-
+	throw(error(instantiation_error, _)).
+
+type_error(ValidType, Culprit) :-
+	throw(error(type_error(ValidType, Culprit), _)).
+
+domain_error(ValidDomain, Culprit) :-
+	throw(error(domain_error(ValidDomain, Culprit), _)).
+
+existence_error(ObjectType, Culprit) :-
+	throw(error(existence_error(ObjectType, Culprit), _)).
+
+permission_error(Operation, PermissionType, Culprit) :-
+	throw(error(permission_error(Operation, PermissionType, Culprit), _)).
+
+representation_error(Flag) :-
+	throw(error(representation_error(Flag), _)).
+
+evaluation_error(Error) :-
+	throw(error(evaluation_error(Error), _)).
+
+resource_error(Resource) :-
+	throw(error(resource_error(Resource), _)).
+
+syntax_error(Error) :-
+	throw(error(syntax_error(Error), _)).