Question about Error.prepareStackTrace

39 views
Skip to first unread message

theratliter theratliter

unread,
Jul 21, 2022, 4:44:08 AM7/21/22
to v8-users
Hi all! I have a question about `Error.prepareStackTrace`.  I want to collect all stacks of error and do not affect the user. V8 document said `the custom prepareStackTrace function is only called once the stack property of Error object is accessed`.  And the code as follows works. Does this code have any problem ?
```
function test() {
    Error.prepareStackTrace = (error, stack) => {
        /*
          collect the stack here
        */
          return error.stack;
    };
    const error = new Error();
    throw error;
}
test();
```

Toon Verwaest

unread,
Jul 25, 2022, 6:46:22 AM7/25/22
to v8-u...@googlegroups.com
As the documentation says: this api is just for rendering the stack, not for trapping all exceptions that are thrown.

The closest you can currently get to that is --print-all-exceptions, but that obviously only works locally and just prints the exceptions.
--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/5f735821-a160-402f-a056-d8b422445a42n%40googlegroups.com.

theratliter theratliter

unread,
Jul 28, 2022, 3:47:54 AM7/28/22
to v8-users
Thank you very much !
Reply all
Reply to author
Forward
0 new messages