Nodes/OmniNodes/Try/Catch (Value Guard) πŸ›Ÿ
ComfyUI Node

Try/Catch (Value Guard) πŸ›Ÿ

Your workflow's seatbelt β€” a value guard, not a real try/except

By TensorVizionΒ·Created 3 months agoΒ·Updated about 8 hours agoΒ· 0
Try/Catch (Value Guard) πŸ›Ÿ
    • value
    • caught
    • summary
    β—„valueβ–Ί
    β—„fallbackβ–Ί
    β—„error_prefixERRORβ–Ί
    β—„treat_empty_string_as_failurefalseβ–Ί

    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_failure is 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 your error_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_failure on.
    • 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.

    CategoryTensorVizion/Workflow

    Inputs (4)

    NameTypeDefaultDescription
    valueSTRINGβ€”
    fallbackSTRINGβ€”
    error_prefixSTRINGERRORβ€”
    treat_empty_string_as_failureBOOLEANfalseβ€”

    Outputs (3)

    NameTypeDescription
    valueSTRINGβ€”
    caughtBOOLEANβ€”
    summarySTRINGβ€”