Printing stack trace on duk_pcall fail with Try/Catch
See original GitHub issueI’m attempting to print a stack trace when a function call fails with duk_pcall().
I can do this with duk_eval_string() pretty easy. Example
std::string str = "try{ MyFunc(); } catch(err){ print('+err.stack+'); }";
duk_eval_string(ctx, str.c_str());
How to get the stack trace from duk_pcall()
duk_push_global_object(ctx);
duk_get_prop_string(ctx, -1, func_name.c_str());
duk_push_string(ctx, param1_name.c_str()); //add parameter
if(duk_pcall(ctx, 1) != 0){
//The function call failed, how do we get the context stack trace?
}
duk_pop(ctx);
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (10 by maintainers)
Top Results From Across the Web
Try-catch printing stack trace - java - Stack Overflow
I have a method which throws a custom exception if a file is formatted the wrong way and it should be caught by...
Read more >How to print exception stack trace in Python? - GeeksforGeeks
The printing stack trace for an exception helps in understanding the error and what went wrong with the code. Not just this, the...
Read more >Error handling in R with tryCatchLog: Catching, logging, post ...
Easy logging of errors, warnings and messages into a file or console; Complete stack trace with references to the source file names and...
Read more >traceback — Print or retrieve a stack traceback — Python 3.11 ...
This is useful when you want to print stack traces under program control, such as in a “wrapper” around the interpreter. The module...
Read more >What is the printStackTrace() method in Java? - Educative.io
It is a method of Java's throwable class which prints the throwable along with other details like the line number and class name...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@aquawicket Was this issue resolved from your point of view?
duk_pcall()is effectively a native-side version of try-catch: