Spaces:
Sleeping
Sleeping
File size: 817 Bytes
097eaf0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | defmodule Firecrawl.Error do
@moduledoc """
Exception raised when the Firecrawl API returns an error response (HTTP 4xx/5xx).
## Fields
* `:status` - The HTTP status code
* `:body` - The decoded response body (typically a map with `"error"` key)
"""
defexception [:status, :body]
@type t :: %__MODULE__{
status: pos_integer(),
body: term()
}
@impl true
def message(%__MODULE__{status: status, body: body}) when is_map(body) do
error_msg =
case body["error"] || body["message"] do
msg when is_binary(msg) -> msg
_ -> inspect(body)
end
"Firecrawl API error (HTTP #{status}): #{error_msg}"
end
def message(%__MODULE__{status: status, body: body}) do
"Firecrawl API error (HTTP #{status}): #{inspect(body)}"
end
end
|