1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-26 00:10:27 +00:00

Don't use janet_stacktrace anymore.

Behavior of janet_stacktrace_ext is more consistent.
This commit is contained in:
Calvin Rose 2021-12-06 08:51:40 -06:00
parent 545c09e202
commit e8ad311d84
3 changed files with 8 additions and 8 deletions

View File

@ -97,7 +97,8 @@ void janet_debug_find(
}
void janet_stacktrace(JanetFiber *fiber, Janet err) {
janet_stacktrace_ext(fiber, err, NULL);
const char *prefix = janet_checktype(err, JANET_NIL) ? NULL : "";
janet_stacktrace_ext(fiber, err, prefix);
}
/* Error reporting. This can be emulated from within Janet, but for
@ -129,9 +130,8 @@ void janet_stacktrace_ext(JanetFiber *fiber, Janet err, const char *prefix) {
/* Print prelude to stack frame */
if (!wrote_error) {
JanetFiberStatus status = janet_fiber_status(fiber);
const char *override_prefix = prefix ? prefix : "";
janet_eprintf("%s%s: %s\n",
override_prefix,
prefix,
janet_status_names[status],
errstr);
wrote_error = 1;

View File

@ -1236,14 +1236,14 @@ JanetFiber *janet_loop1(void) {
int is_suspended = sig == JANET_SIGNAL_EVENT || sig == JANET_SIGNAL_YIELD || sig == JANET_SIGNAL_INTERRUPT;
if (NULL == sv) {
if (!is_suspended) {
janet_stacktrace(task.fiber, res);
janet_stacktrace_ext(task.fiber, res, "");
}
} else if (sig == JANET_SIGNAL_OK || (task.fiber->flags & (1 << sig))) {
JanetChannel *chan = janet_channel_unwrap(sv);
janet_channel_push(chan, make_supervisor_event(janet_signal_names[sig],
task.fiber, chan->is_threaded), 2);
} else if (!is_suspended) {
janet_stacktrace(task.fiber, res);
janet_stacktrace_ext(task.fiber, res, "");
}
if (sig == JANET_SIGNAL_INTERRUPT) {
/* On interrupts, return the interrupted fiber immediately */

View File

@ -50,7 +50,7 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
fiber->env = env;
JanetSignal status = janet_continue(fiber, janet_wrap_nil(), &ret);
if (status != JANET_SIGNAL_OK && status != JANET_SIGNAL_EVENT) {
janet_stacktrace(fiber, ret);
janet_stacktrace_ext(fiber, ret, "");
errflags |= 0x01;
done = 1;
}
@ -58,7 +58,7 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
ret = janet_wrap_string(cres.error);
if (cres.macrofiber) {
janet_eprintf("compile error in %s: ", sourcePath);
janet_stacktrace(cres.macrofiber, ret);
janet_stacktrace_ext(cres.macrofiber, ret, "");
} else {
janet_eprintf("compile error in %s: %s\n", sourcePath,
(const char *)cres.error);
@ -121,7 +121,7 @@ int janet_loop_fiber(JanetFiber *fiber) {
Janet out;
status = janet_continue(fiber, janet_wrap_nil(), &out);
if (status != JANET_SIGNAL_OK && status != JANET_SIGNAL_EVENT) {
janet_stacktrace(fiber, out);
janet_stacktrace_ext(fiber, out, "");
}
#endif
return status;