node-java icon indicating copy to clipboard operation
node-java copied to clipboard

Anyway to get some local (node) stacktrace when a Java error occurs?

Open newhouse opened this issue 4 years ago • 1 comments

When a call to Java throws an exception, the Error object in Node (always? often?) seems to only include the stacktrace on the Java side of things. This is of course helpful, but sometimes it can be a bit tough to figure out which call-site on the Node side of things led to the call that caused the Java exception.

Is there a way to add/combine the Node stack trace as well, perhaps stripping out the parts of the trace that occur within this library?

Forgive me if this has been asked before...I'd also be willing to contribute a PR if you think this is something you'd accept and could guide me a bit.

newhouse avatar Oct 13 '21 23:10 newhouse

Bump @joeferner

I'm running into this pain-point more and more, and would like to figure out a solution.

I tried monkey-patching some of the internals of this library to essentially wrap the synchronous and asynchronous calls in try / catch so that I could handle things that way, but it didn't work.

Is there a way to accomplish this? My gut says that either the library might want to support this localization or merging/combination of stack traces...or at the very least offer a "hook" for extra/custom error handling, or the ability to wrap the underlying calls in order to do something custom such as try / catch logic there?

newhouse avatar Nov 02 '21 17:11 newhouse