LLMProxy.HTTP.ErrorResponse (llm_proxy v0.1.1)

Copy Markdown View Source

Renders sanitized public error envelopes for supported HTTP protocols.

Internal terms and exception details must be projected before this boundary. This module accepts only stable message/code fields and chooses the native Anthropic Messages envelope when the request path targets that API.

Summary

Types

error_map()

@type error_map() :: %{required(String.t()) => term()}

Functions

openai_error(status, error)

@spec openai_error(pos_integer(), map()) :: error_map()

openai_error(status, code, message)

@spec openai_error(pos_integer(), String.t(), term()) :: error_map()

safe_message(message, fallback)

@spec safe_message(term(), String.t()) :: String.t()

send(conn, status, code, message)

@spec send(Plug.Conn.t(), pos_integer(), String.t(), term()) :: Plug.Conn.t()

send_anthropic(conn, status, type, message)

@spec send_anthropic(Plug.Conn.t(), pos_integer(), String.t(), term()) ::
  Plug.Conn.t()

send_openai(conn, status, error)

@spec send_openai(Plug.Conn.t(), pos_integer(), map()) :: Plug.Conn.t()

send_openai(conn, status, code, message)

@spec send_openai(Plug.Conn.t(), pos_integer(), String.t(), term()) :: Plug.Conn.t()