Proposal: Graph-wide default error handler for StateGraph (fallback for nodes without error_handler)

Post body (copy/paste)

Context

I’m following up on an earlier GitHub issue:

The node-level error_handler from #7233 solved the original problem and has already helped me a lot.

What still feels missing

I’m now hitting a separate ergonomics gap in larger graphs.

When many nodes should share the same recovery behavior, setting error_handler node-by-node becomes repetitive. I can do it, but it adds a lot of boilerplate.

What I already understand exists

I know run-level callbacks can observe graph success/failure and update external systems.

That helps for “always update backend run status on success/error,” but it doesn’t solve in-graph recovery behavior where I want fallback logic that can receive NodeError and return Command / state
updates.

Proposal

Would it make sense to add a graph-wide default error handler for StateGraph, used only when a node does not define its own error_handler?

Example API shape:

builder = StateGraph(State)
builder.set_default_error_handler(handler)

## Desired precedence

1. Node-level error_handler (if present)
2. Graph-level default error handler
3. Current failure propagation

## Desired semantics (non-breaking)

- Runs after retries are exhausted
- interrupt() behavior stays unchanged
- Handler receives NodeError
- Handler may return Command
- If the handler raises, error propagates as today

## Non-goals

- Not overriding explicit node handlers
- Not changing retry semantics
- Not introducing breaking changes

## Why this helps in practice

In background-job workflows, many nodes need the same failure fallback (for example, write failure metadata and route cleanly), while a few nodes still need custom handlers. A graph-wide fallback would
reduce repeated config significantly while preserving current behavior.

If this direction makes sense, I’m happy to contribute the implementation.

@gouveags can you please check this out? I think the per-node error_handler should already override this. Please let us know if his doesn’t help.

Great stuff! Worked just fine! Thanks for the help!