How can I get backtraces from user-supplied scripts? #1011
Unanswered
ianthehenry
asked this question in
Q&A
Replies: 2 comments 5 replies
-
What is |
Beta Was this translation helpful? Give feedback.
2 replies
-
I should also mention the janet_dostring is probably not the best way to do this, even with user provided input. If you have any significant amount of code in Janet rather than C, you should probably load your user script with Janet, using |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on a program that takes a user-written Janet script as input, runs it, and then does something with the result. I'd like to be able to report
line:col
for errors in the user script, but it seems that Janet usually doesn't provide them. For example this program:That gives me the line of the
(something)
call -- the thing I am actually interested in (imagine thatsomething
is not user-defined, but is already defined in the environment I provide to the user). But if I do anything except a top-level function invocation:I only get the line that raises the error, not the location in the user's code.
Currently I'm just using
janet_dofile
, because it was easy to get started with. I'm not sure if this error tracing is a limitation ofjanet_dofile
or of Janet itself. So far I can't come up with any workarounds that give me useful backtraces (i.e. wrapping everything in functions to try to force a stack entry (?), or fibers and manuallydebug/stacktrace
ing).Is there a chance that wrapping everything in a function and using
janet_pcall
will make this better? Is there another approach I should be looking at? Or is this just not something Janet will be able to provide?Beta Was this translation helpful? Give feedback.
All reactions