diff options
author | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-19 13:12:59 +0000 |
---|---|---|
committer | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-19 13:12:59 +0000 |
commit | 6b3d59a3256a292b582e4313325ca14154211671 (patch) | |
tree | ecf0caa97c0596697aca1abac923d9fa5c95925c /repl.pl | |
parent | 1b73b6d1323c69c0086a41bf85a9b85003377a3b (diff) |
Print errors better in the repl
Diffstat (limited to 'repl.pl')
-rw-r--r-- | repl.pl | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -75,11 +75,58 @@ write_bindings([Var = Val|Bs]) :- ), write_bindings(Bs). +print_exception(error(E, _)) :- + write('Unhandled error: + '), % \n\t + print_error(E), + nl. print_exception(E) :- + E \= error(_,_), write('Unhandled exception: '), write(E), nl. +print_error(instantiation_error) :- + write('instantiation error'). +print_error(type_error(ValidType, Culprit)) :- + write('type error, expected '), + write(ValidType), + write(': '), + write(Culprit). +print_error(domain_error(ValidDomain, Culprit)) :- + write('domain error, expected '), + write(ValidDomain), + write(': '), + write(Culprit). +print_error(existence_error(ObjectType, Culprit)) :- + write('existence error, '), + write(Culprit), + write(' is not an existing object of type: '), + write(ObjectType). +print_error(permission_error(Operation, Type, Culprit)) :- + write('permission error, cannot '), + write(Operation), + write(' '), + write(Type), + write(': '), + write(Culprit). +print_error(representation_error(Flag)) :- + write('representation error: '), + write(Flag). +print_error(evaluation_error(Error)) :- + write('evaluation error: '), + write(Error). +print_error(resource_error(Res)) :- + write('resource error: '), + write(Res). +print_error(syntax_error(E)) :- + write('syntax error: '), + write(E). +print_error(system_error) :- + write('system error'). +print_error(E) :- + write(E). + whitespace(' '). whitespace(' '). whitespace(' |