#rusty_v8 extracting stack trace when a promise rejects

3 messages · Page 1 of 1 (latest)

tacit owl
#

Hi, i am trying to get the stack trace and print it out when a promise rejects.

if promise.state() == v8::PromiseState::Rejected {
  let exception = promise.result(scope);
  retval = exception.to_rust_string_lossy(scope);

  if exception.is_native_error() {
   //how to get the exception stack trace to print here?
   // i have retval from above, but it is just the oneliner eg:TypeError: Assignment to constant variable.
   
 }
 

in the above example, i have the retval as the exception string which contains something like TypeError: Assignment to constant variable.. But how do i extract exception stack trace and get the line number and other details as well from this?

hazy geyser
#

I'm not totally sure, but can you just use the object getter for the stack property?

#

I read the rusty_v8 docs a bit more, and it looks like you can use v8::Exception::stack_trace(scope, exception)