{"record":{"id":"871427ece6fd816e","repo":"langchain-ai/langgraph","slug":"all-types-in-the-error-handler-error-annotation-mu","errorCode":null,"errorMessage":"All types in the error handler error annotation must be Exception types. For example, `def custom_handler(e: Union[ValueError, TypeError])`. Got '{annotation}' instead.","messagePattern":"All types in the error handler error annotation must be Exception types\\. For example, `def custom_handler\\(e: Union\\[ValueError, TypeError\\]\\)`\\. Got '(.+?)' instead\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/prebuilt/langgraph/prebuilt/tool_node.py","lineNumber":490,"sourceCode":"        if params[0].name in [\"self\", \"cls\"] and len(params) == 2:\n            first_param = params[1]\n        else:\n            first_param = params[0]\n\n        type_hints = get_type_hints(handler)\n        if first_param.name in type_hints:\n            origin = get_origin(first_param.annotation)\n            if origin in [Union, UnionType]:\n                args = get_args(first_param.annotation)\n                if all(issubclass(arg, Exception) for arg in args):\n                    return tuple(args)\n                msg = (\n                    \"All types in the error handler error annotation must be \"\n                    \"Exception types. For example, \"\n                    \"`def custom_handler(e: Union[ValueError, TypeError])`. \"\n                    f\"Got '{first_param.annotation}' instead.\"\n                )\n                raise ValueError(msg)\n\n            exception_type = type_hints[first_param.name]\n            if Exception in exception_type.__mro__:\n                return (exception_type,)\n            msg = (\n                f\"Arbitrary types are not supported in the error handler \"\n                f\"signature. Please annotate the error with either a \"\n                f\"specific Exception type or a union of Exception types. \"\n                \"For example, `def custom_handler(e: ValueError)` or \"\n                \"`def custom_handler(e: Union[ValueError, TypeError])`. \"\n                f\"Got '{exception_type}' instead.\"\n            )\n            raise ValueError(msg)\n\n    # If no type information is available, return (Exception,)\n    # for backwards compatibility.\n    return (Exception,)\n","sourceCodeStart":472,"sourceCodeEnd":508,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/prebuilt/langgraph/prebuilt/tool_node.py#L472-L508","documentation":"Error \"All types in the error handler error annotation must be Exception types. For example, `def custom_handler(e: Union[ValueError, TypeError])`. Got '{annotation}' instead.\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:490 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}