nodely icon indicating copy to clipboard operation
nodely copied to clipboard

Exception Handler

Open jtrunick opened this issue 1 year ago • 2 comments

Being able to specify an exception handler would be very useful for my case.

jtrunick avatar Mar 14 '24 16:03 jtrunick

Can you specify what kind of use case you would like to support?

The current expectation is that whenever we use api/eval or equivalent, if any uncaught exception happens within a node, this exception is going to bubble up to the caller, so you could just wrap eval within a try/catch block.

If you want to an exception to be handled in a specific node you can also put the try/catch within the node definition.

sovelten avatar Jan 30 '25 18:01 sovelten

A handler might decide to ignore the error and return a default value, or might collect multiple exceptions and throw them when finished. I'd prefer to centralize that w/o wrapping each node definition.

jtrunick avatar Jan 31 '25 05:01 jtrunick

@jtrunick Can you evaluate if #51 addresses your use case? (using with-try macro).

sovelten avatar Oct 16 '25 17:10 sovelten

@sovelten Sorry I missed your ask earlier. If I want to know which node in an env (specifically the keyword in the map for the node) is responsible for the exception, do you have a suggestion on how I could implement that?

I can see somehow associating the keyword with the node before running the DAG. I see this with-try is operating on the environment for each value/node it would be nice I could catch a clojure exception with info to it's corresponding key/word. I could pass any Java exception as the cause and rethrow if i like. I think this would make for a friendlier messaging ("while evaluating node :x...").

jtrunick avatar Nov 18 '25 15:11 jtrunick