mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 08:20:27 +00:00
Don't use janet_stacktrace anymore.
Behavior of janet_stacktrace_ext is more consistent.
This commit is contained in:
parent
545c09e202
commit
e8ad311d84
@ -97,7 +97,8 @@ void janet_debug_find(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void janet_stacktrace(JanetFiber *fiber, Janet err) {
|
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
|
/* 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 */
|
/* Print prelude to stack frame */
|
||||||
if (!wrote_error) {
|
if (!wrote_error) {
|
||||||
JanetFiberStatus status = janet_fiber_status(fiber);
|
JanetFiberStatus status = janet_fiber_status(fiber);
|
||||||
const char *override_prefix = prefix ? prefix : "";
|
|
||||||
janet_eprintf("%s%s: %s\n",
|
janet_eprintf("%s%s: %s\n",
|
||||||
override_prefix,
|
prefix,
|
||||||
janet_status_names[status],
|
janet_status_names[status],
|
||||||
errstr);
|
errstr);
|
||||||
wrote_error = 1;
|
wrote_error = 1;
|
||||||
|
@ -1236,14 +1236,14 @@ JanetFiber *janet_loop1(void) {
|
|||||||
int is_suspended = sig == JANET_SIGNAL_EVENT || sig == JANET_SIGNAL_YIELD || sig == JANET_SIGNAL_INTERRUPT;
|
int is_suspended = sig == JANET_SIGNAL_EVENT || sig == JANET_SIGNAL_YIELD || sig == JANET_SIGNAL_INTERRUPT;
|
||||||
if (NULL == sv) {
|
if (NULL == sv) {
|
||||||
if (!is_suspended) {
|
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))) {
|
} else if (sig == JANET_SIGNAL_OK || (task.fiber->flags & (1 << sig))) {
|
||||||
JanetChannel *chan = janet_channel_unwrap(sv);
|
JanetChannel *chan = janet_channel_unwrap(sv);
|
||||||
janet_channel_push(chan, make_supervisor_event(janet_signal_names[sig],
|
janet_channel_push(chan, make_supervisor_event(janet_signal_names[sig],
|
||||||
task.fiber, chan->is_threaded), 2);
|
task.fiber, chan->is_threaded), 2);
|
||||||
} else if (!is_suspended) {
|
} else if (!is_suspended) {
|
||||||
janet_stacktrace(task.fiber, res);
|
janet_stacktrace_ext(task.fiber, res, "");
|
||||||
}
|
}
|
||||||
if (sig == JANET_SIGNAL_INTERRUPT) {
|
if (sig == JANET_SIGNAL_INTERRUPT) {
|
||||||
/* On interrupts, return the interrupted fiber immediately */
|
/* On interrupts, return the interrupted fiber immediately */
|
||||||
|
@ -50,7 +50,7 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
|
|||||||
fiber->env = env;
|
fiber->env = env;
|
||||||
JanetSignal status = janet_continue(fiber, janet_wrap_nil(), &ret);
|
JanetSignal status = janet_continue(fiber, janet_wrap_nil(), &ret);
|
||||||
if (status != JANET_SIGNAL_OK && status != JANET_SIGNAL_EVENT) {
|
if (status != JANET_SIGNAL_OK && status != JANET_SIGNAL_EVENT) {
|
||||||
janet_stacktrace(fiber, ret);
|
janet_stacktrace_ext(fiber, ret, "");
|
||||||
errflags |= 0x01;
|
errflags |= 0x01;
|
||||||
done = 1;
|
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);
|
ret = janet_wrap_string(cres.error);
|
||||||
if (cres.macrofiber) {
|
if (cres.macrofiber) {
|
||||||
janet_eprintf("compile error in %s: ", sourcePath);
|
janet_eprintf("compile error in %s: ", sourcePath);
|
||||||
janet_stacktrace(cres.macrofiber, ret);
|
janet_stacktrace_ext(cres.macrofiber, ret, "");
|
||||||
} else {
|
} else {
|
||||||
janet_eprintf("compile error in %s: %s\n", sourcePath,
|
janet_eprintf("compile error in %s: %s\n", sourcePath,
|
||||||
(const char *)cres.error);
|
(const char *)cres.error);
|
||||||
@ -121,7 +121,7 @@ int janet_loop_fiber(JanetFiber *fiber) {
|
|||||||
Janet out;
|
Janet out;
|
||||||
status = janet_continue(fiber, janet_wrap_nil(), &out);
|
status = janet_continue(fiber, janet_wrap_nil(), &out);
|
||||||
if (status != JANET_SIGNAL_OK && status != JANET_SIGNAL_EVENT) {
|
if (status != JANET_SIGNAL_OK && status != JANET_SIGNAL_EVENT) {
|
||||||
janet_stacktrace(fiber, out);
|
janet_stacktrace_ext(fiber, out, "");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return status;
|
return status;
|
||||||
|
Loading…
Reference in New Issue
Block a user