print errors as goals (#1408)

This commit is contained in:
Mark Thom
2022-04-09 14:01:48 -06:00
parent 0876d46880
commit 00eab4d415
3 changed files with 27 additions and 19 deletions

View File

@@ -17,6 +17,14 @@
:- use_module(library(pairs)).
write_error(Error) :-
write(' '),
( nonvar(Error),
functor(Error, error, 2) ->
writeq(Error)
; writeq(throw(Error))
).
'$print_message_and_fail'(Error) :-
( ( Error = error(existence_error(procedure, Expansion), Expansion)
; Error = error(evaluation_error((_:_)/_),Expansion)
@@ -25,12 +33,10 @@
; Expansion = term_expansion/2
) ->
true
; write('caught: '),
writeq(Error),
; write_error(Error),
nl
)
; write('caught: '),
writeq(Error),
; write_error(Error),
nl
),
'$fail'.