Try/Catch (Value Guard) π
Your workflow's seatbelt β a value guard, not a real try/except
- value
- caught
- summary
The name promises a programming construct ComfyUI can't actually deliver, and the author knows it. The Try/Catch (Value Guard) node from TensorVizion/OmniNodes doesn't intercept crashes - nothing in any custom pack can, because an uncaught Python exception halts a node and everything downstream of it regardless of what you wire after it. What it does do is check a value for the common "this quietly failed" signals and substitute a fallback, so a soft failure a few nodes upstream doesn't poison a long batch run.
That's still genuinely useful, because ComfyUI's Web API ecosystem has settled on a pattern: catch the exception inside the node, and return an error marker instead of raising. This node is the reusable "if that marker shows up, swap in something safe" step - so you don't have to bolt bespoke fallback routing onto every upstream node yourself.
How it checks
The failure test runs in a clear order:
- value is
Noneβ failed - value is an empty string β failed, only if
treat_empty_string_as_failureis on (default off, so a legitimately blank string passes) - value is a string starting with
error_prefix(default"ERROR") β failed - value is a float/int that is NaN or Β±Inf β failed
If none match, the value passes through untouched and caught is False. If one matches, fallback is returned instead and caught flips to True - which you can wire into a Conditional Gate or a notify node to learn a fallback fired, instead of silently continuing.
Inputs and outputs
Inputs: value (the thing to guard), fallback (what to substitute), error_prefix (what counts as an error string, default "ERROR"), and treat_empty_string_as_failure (boolean). Outputs: value (guarded), caught (BOOLEAN), and summary (STRING explaining what happened and why).
Install
Ships with OmniNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/TensorVizion/OmniNodes
Or ComfyUI Manager β OmniNodes β restart. Pure Python standard library. Under TensorVizion/Workflow.
Troubleshooting
- A crash still kills the queue - correct, and unavoidable. This node only guards values that arrived from an upstream node's own error handling. If an upstream node raises, no guard after it can help.
- Fallback never fires - check what the failure actually looks like. If the upstream returns
"Error: ..."with a different prefix than yourerror_prefix, the guard can't see it. Match the prefix to the node's real error format. - Empty string passes when you expected a catch - that's the default toggle; flip
treat_empty_string_as_failureon. - Node missing - restart and check the terminal
[OmniNodes]log.
Use it in long, unattended batch runs where one soft failure shouldn't invalidate everything downstream. It's a seatbelt, not airbags - know which one you're getting.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| value | STRING | β | |
| fallback | STRING | β | |
| error_prefix | STRING | ERROR | β |
| treat_empty_string_as_failure | BOOLEAN | false | β |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| value | STRING | β |
| caught | BOOLEAN | β |
| summary | STRING | β |