LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdkauthexceptionsHTTPException
    Classā—Since v0.1

    HTTPException

    Copy
    HTTPException(
      self,
      status_code: int = 401,
      detail: str | None = None,
      

    Bases

    Exception

    Constructors

    Attributes

    View source on GitHub
    headers
    :
    Mapping
    [
    str
    ,
    str
    ]
    |
    None
    =
    None
    )

    Parameters

    NameTypeDescription
    status_codeint
    Default:401

    HTTP status code for the error. Defaults to 401 "Unauthorized".

    detailstr | None
    Default:None

    Detailed error message. If None, uses a default message based on the status code.

    headersMapping[str, str] | None
    Default:None
    constructor
    __init__
    NameType
    status_codeint
    detailstr | None
    headersMapping[str, str] | None
    attribute
    status_code: status_code
    attribute
    detail: detail
    attribute
    headers: headers

    HTTP exception that you can raise to return a specific HTTP error response.

    Since this is defined in the auth module, we default to a 401 status code.

    Example:

    Default:

    raise HTTPException()
    # HTTPException(status_code=401, detail='Unauthorized')

    Add headers:

    raise HTTPException(headers={"X-Custom-Header": "Custom Value"})
    # HTTPException(status_code=401, detail='Unauthorized', headers={"WWW-Authenticate": "Bearer"})

    Custom error:

    raise HTTPException(status_code=404, detail="Not found")

    Additional HTTP headers to include in the error response.