LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coretoolsbaseBaseToolhandle_tool_error
    Attributeā—Since v0.2

    handle_tool_error

    Copy
    handle_tool_error: bool | str | Callable[[ToolException], ToolExceptionHandlerOutput] | None
    View source on GitHub
    =
    False

    Handle ToolException raised by tool execution.

    If False, the exception is re-raised. If True, the exception message is returned as tool output. If a string is passed, that string is returned as tool output. If a callable is passed, it receives the exception and its return value is used as the tool output.

    Callable handlers may return either a string or a list of message content blocks. If the tool was invoked with a tool_call_id, the handled content is wrapped in a ToolMessage with status="error".