View source with raw comments or as raw
    1/*  Part of SWI-Prolog
    2
    3    WWW:           http://www.swi-prolog.org
    4    Copyright (c)  2021, SWI-Prolog Solutions b.v.
    5    All rights reserved.
    6
    7    Redistribution and use in source and binary forms, with or without
    8    modification, are permitted provided that the following conditions
    9    are met:
   10
   11    1. Redistributions of source code must retain the above copyright
   12       notice, this list of conditions and the following disclaimer.
   13
   14    2. Redistributions in binary form must reproduce the above copyright
   15       notice, this list of conditions and the following disclaimer in
   16       the documentation and/or other materials provided with the
   17       distribution.
   18
   19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   20    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   21    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   22    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   23    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   24    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   25    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   26    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   27    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   29    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   30    POSSIBILITY OF SUCH DAMAGE.
   31*/
   32
   33:- module(types,
   34	  [ must_be/4,			% +Term, +Type, +Goal, +ArgNo
   35	    illarg/3,			% +ErrorTerm, +Goal, +ArgNo
   36	    illarg/4			% +ErrorTerm, +Goal, +ArgNo, +Culprit
   37	  ]).   38:- use_module(library(error)).

SICStus 4 library(types).

See also
- https://sicstus.sics.se/sicstus/docs/4.6.0/html/sicstus/lib_002dtypes.html */
 must_be(+Term, +Type, +Goal, +ArgNo) is det
Similar to must_be/2. This emulation currently only accepts types that SWI-Prolog must_be/2 understands natively.

The Goal and ArgNo arguments are currently ignored.

   52must_be(Term, Type, _Goal, _ArgNo) :- must_be(Type, Term).
 illarg(+ErrorTerm, +Goal, +ArgNo) is det
Same as illarg/4, with Culprit set to argument number ArgNo of Goal. The Goal and ArgNo arguments are otherwise not included in the thrown error.
   60illarg(ErrorTerm, Goal, ArgNo) :-
   61	arg(ArgNo, Goal, Culprit),
   62	illarg(ErrorTerm, Goal, ArgNo, Culprit).
 illarg(+ErrorTerm, +Goal, +ArgNo, +Culprit) is det
Throw a SICStus standard error described by ErrorTerm. If possible, errors are thrown in the corresponding SWI-Prolog format using library(error). If a SICStus error has no SWI-Prolog counterpart, it is thrown in the same format that SICStus would use.

The Goal and ArgNo arguments are currently always ignored. Depending on the requested error type, Culprit and/or parts of ErrorTerm may also be ignored.

   76illarg(var, _Goal, _ArgNo, Culprit) :-
   77	instantiation_error(Culprit).
   78illarg(type(ErrorType), Goal, ArgNo, Culprit) :-
   79	% Equivalent according to SICStus docs.
   80	must_be(Culprit, ErrorType, Goal, ArgNo).
   81illarg(domain(ErrorType, ErrorDomain), Goal, ArgNo, Culprit) :-
   82	must_be(Culprit, ErrorType, Goal, ArgNo),
   83	domain_error(ErrorDomain, Culprit).
   84illarg(force_type(ExpType), _Goal, _ArgNo, Culprit) :-
   85	type_error(ExpType, Culprit).
   86illarg(context(ContextType, CommandType), _Goal, _ArgNo, _Culprit) :-
   87	throw(error(context_error(ContextType, CommandType), _)).
   88illarg(existence(ObjType, Culprit, _Message), _Goal, _ArgNo, _CulpritOther) :-
   89	existence_error(ObjType, Culprit).
   90illarg(permission(Operation, ObjType, _Message), _Goal, _ArgNo, Culprit) :-
   91	permission_error(Operation, ObjType, Culprit).
   92illarg(representation(ErrorType), _Goal, _ArgNo, _Culprit) :-
   93	representation_error(ErrorType).
   94illarg(evaluation(ErrorType), _Goal, _ArgNo, _Culprit) :-
   95	throw(error(evaluation_error(ErrorType), _)).
   96illarg(consistency(Culprit1, Culprit2, Message), _Goal, _ArgNo, _CulpritOther) :-
   97	throw(error(consistency_error(Culprit1, Culprit2, Message), _)).
   98illarg(syntax(_Pos, Msg, _Tokens, _AfterError), _Goal, _ArgNo, _Culprit) :-
   99	syntax_error(Msg).
  100illarg(resource(Resource), _Goal, _ArgNo, _Culprit) :-
  101	resource_error(Resource).
  102illarg(system(_Message), _Goal, _ArgNo, _Culprit) :-
  103	throw(error(system_error, _))