domain_error/2
Description
domain_error(Domain, Culprit)
Throws a domain error. Used when an argument is of the correct type but outside the valid domain. For example, trying to use an atom as an operator specifier that is not a valid specifier. This built-in method is declared private and thus cannot be used as a message to an object. Calling this predicate is equivalent to the following sequence of goals:
...,
context(Context),
throw(error(domain_error(Domain,Culprit), Context)).
This allows the user to generate errors in the same format used by the runtime.
Possible values for Domain include:
character_code_listclose_optionflag_optionflag_valuecompiler_flagflagprolog_flagio_modenon_empty_listnot_less_than_zerooperator_priorityoperator_specifierread_optionsource_sinkstreamstream_optionstream_or_aliasstream_positionstream_propertywrite_optioncharacter_code_listtext_encodingdirectiveobject_directiveprotocol_directivecategory_directiveobject_relationprotocol_relationcategory_relationobject_propertyprotocol_propertycategory_propertypredicate_propertymeta_argument_specifiermeta_directive_templateclosureallocationredefinitionmessage_sending_goalclassprototypescopeboolean
The value of Culprit is the argument or one of its sub-terms that caused
the error.
Modes and number of proofs
domain_error(+atom, @nonvar) - error
Errors
domain_error(Domain, Culprit)Examples
...,
atom(Color),
\+ color(Color),
domain_error(color, Color).