mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +02:00
Issue #111 - Improve output of error messages
This commit is contained in:
parent
84cf5f2d08
commit
2b1f2e8e57
2 changed files with 17 additions and 4 deletions
8
icyc.scm
8
icyc.scm
|
@ -38,14 +38,18 @@
|
|||
(display "Error: ")
|
||||
(cond
|
||||
((pair? obj)
|
||||
(when (string? (car obj))
|
||||
(display (car obj))
|
||||
(display ": ")
|
||||
(set! obj (cdr obj)))
|
||||
(for-each
|
||||
(lambda (o)
|
||||
(display o)
|
||||
(write o)
|
||||
(display " "))
|
||||
obj))
|
||||
(else
|
||||
(display obj)))
|
||||
(display "\n")
|
||||
(newline)
|
||||
(k #t))
|
||||
(lambda ()
|
||||
(repl)))))
|
||||
|
|
13
runtime.c
13
runtime.c
|
@ -423,6 +423,7 @@ object Cyc_glo_eval_from_c = NULL;
|
|||
object Cyc_default_exception_handler(void *data, int argc, closure _,
|
||||
object err)
|
||||
{
|
||||
int is_msg = 1;
|
||||
fprintf(stderr, "Error: ");
|
||||
|
||||
if ((err == NULL) || is_value_type(err) || type_of(err) != pair_tag) {
|
||||
|
@ -431,8 +432,16 @@ object Cyc_default_exception_handler(void *data, int argc, closure _,
|
|||
// Error is list of form (type arg1 ... argn)
|
||||
err = cdr(err); // skip type field
|
||||
for (; (err != NULL); err = cdr(err)) { // output with no enclosing parens
|
||||
Cyc_display(car(err), stderr);
|
||||
fprintf(stderr, " ");
|
||||
if (is_msg &&
|
||||
is_object_type(car(err)) &&
|
||||
type_of(car(err)) == string_tag) {
|
||||
is_msg = 0;
|
||||
Cyc_display(car(err), stderr);
|
||||
fprintf(stderr, ": ");
|
||||
} else {
|
||||
Cyc_write(car(err), stderr);
|
||||
fprintf(stderr, " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue