diff --git a/src/core/debug.c b/src/core/debug.c index ad9f0418..f433869b 100644 --- a/src/core/debug.c +++ b/src/core/debug.c @@ -100,6 +100,9 @@ void janet_stacktrace(JanetFiber *fiber, Janet err) { JanetFiber **fibers = NULL; int wrote_error = 0; + int print_color = janet_truthy(janet_dyn("err-color")); + if (print_color) fprintf(out, "\x1b[31m"); + while (fiber) { janet_v_push(fibers, fiber); fiber = fiber->child; @@ -157,6 +160,8 @@ void janet_stacktrace(JanetFiber *fiber, Janet err) { } } + if (print_color) fprintf(out, "\x1b[0m"); + janet_v_free(fibers); } diff --git a/src/core/vm.c b/src/core/vm.c index 4b9de1d1..21bec2e8 100644 --- a/src/core/vm.c +++ b/src/core/vm.c @@ -179,7 +179,7 @@ static void vm_do_trace(JanetFunction *func) { static Janet call_nonfn(JanetFiber *fiber, Janet callee) { int32_t argn = fiber->stacktop - fiber->stackstart; Janet ds, key; - if (argn != 1) janet_panicf("%v called with arity %d, expected 1", callee, argn); + if (argn != 1) janet_panicf("%v called with %d arguments, possibly expected 1", callee, argn); if (janet_checktypes(callee, JANET_TFLAG_INDEXED | JANET_TFLAG_DICTIONARY | JANET_TFLAG_STRING | JANET_TFLAG_BUFFER | JANET_TFLAG_ABSTRACT)) { ds = callee; @@ -195,7 +195,7 @@ static Janet call_nonfn(JanetFiber *fiber, Janet callee) { /* Get a callable from a keyword method name and check ensure that it is valid. */ static Janet resolve_method(Janet name, JanetFiber *fiber) { int32_t argc = fiber->stacktop - fiber->stackstart; - if (argc < 1) janet_panicf("method call takes at least 1 argument, got %d", argc); + if (argc < 1) janet_panicf("method call (%v) takes at least 1 argument, got 0", name); Janet callee = janet_get(fiber->data[fiber->stackstart], name); if (janet_checktype(callee, JANET_NIL)) janet_panicf("unknown method %v invoked on %v", name, fiber->data[fiber->stackstart]); diff --git a/src/mainclient/init.janet b/src/mainclient/init.janet index 72daac4e..c6b6fbaf 100644 --- a/src/mainclient/init.janet +++ b/src/mainclient/init.janet @@ -92,4 +92,5 @@ (getter (prompter p) buf)) (def onsig (if *quiet* (fn [x &] x) nil)) (setdyn :pretty-format (if *colorize* "%.20P" "%.20p")) + (setdyn :err-color (if *colorize* true)) (repl getchunk onsig)))