LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Browser
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
  • Tools
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Decisions
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Compat
  • Event
  • Llms
  • Openai Completions Stream
  • Profile
  • Stream
  • Structured Output
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Testing
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Gateway
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Standard Schema
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Uuid
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

Chat LangChain

What can I help with?

Enter to sendĀ·Shift+Enter new line

Menu

LangChain
BrowserUniversalHubNodeLoadSerializableEncoder BackedFile SystemIn MemoryTools
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextDecisionsBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsCompatEventLlmsOpenai Completions StreamProfileStreamStructured OutputLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryTestingToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingGatewayHashJson PatchJson SchemaMathSsrfStandard SchemaStreamTestingTiktokenTypesUuidVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/coreerrors
Moduleā—Since v1.4

errors

Copy
import { ... } from "@langchain/core/errors";

Functions

function
getRetryable→ boolean | undefined

Read an error's retryability mark.

function
stampRetryable→ T

Mark an error as safe or unsafe to retry.

Sets a non-enumerable symbol on the error itself, leaving its class and shape untouched, so it is safe to apply to a provider SDK's own error.

deprecatedfunction
addLangChainErrorFields→ any

Classes

class
ContextOverflowError

Error class representing a context window overflow in a language model operation.

This error is thrown when the combined input to a language model (such as prompt tokens, historical messages, and/or instructions) exceeds the maximum context window or token limit that the model can process in a single request. Most models have defined upper limits for the number of tokens or characters allowed in a context, and exceeding this limit will prevent the operation from proceeding.

The ContextOverflowError extends the LangChainError base class with the marker "context-overflow".

class
LangChainError

Base error class for all LangChain errors.

All LangChain error classes should extend this class (directly or indirectly). Use LangChainError.isInstance(obj) to check if an object is any LangChain error.

class
ModelAbortError

Error class representing an aborted model operation in LangChain.

This error is thrown when a model operation (such as invocation, streaming, or batching) is cancelled before it completes, commonly due to a user-initiated abort signal (e.g., via an AbortController) or an upstream cancellation event.

The ModelAbortError provides access to any partial output the model may have produced before the operation was interrupted, which can be useful for resuming work, debugging, or presenting incomplete results to users.

class
ModelRefusalError

Error class representing a model refusal.

Providers report a refusal, such as a safety-policy refusal, as a successful response rather than an error. LangChain raises this error where a refusal cannot be treated as an answer, for example when structured output has nothing to parse, or when an agent uses refusal middleware.

The ModelRefusalError extends the LangChainError base class with the marker "model-refusal". Retrying the same request is unlikely to succeed, so the error is marked as not retryable.

Type Aliases

typeAlias
BrandedClass: TBase & __type

The return type of Namespace.brand(): the original base class intersected with a polymorphic isInstance type guard.

typeAlias
LangChainErrorCodes: "CONTEXT_OVERFLOW" | "INVALID_PROMPT_INPUT" | "INVALID_TOOL_RESULTS" | "MESSAGE_COERCION_FAILURE" | "MODEL_AUTHENTICATION" | "MODEL_NOT_FOUND" | "MODEL_RATE_LIMIT" | "OUTPUT_PARSING_FAILURE" | "MODEL_ABORTED"

Variables

variable
ns: Namespace

The error namespace for all LangChain errors

View source on GitHub