ML-21: Classify API errors as transient vs permanent

This commit is contained in:
Claudio Ortolina
2026-04-24 13:55:00 +01:00
parent be4f4686f8
commit a1c665b490
43 changed files with 1429 additions and 135 deletions
+2 -2
View File
@@ -76,14 +76,14 @@ defmodule BraveSearchTest do
end
@tag :capture_log
test "returns the decoded error body on non-200 responses" do
test "returns an ErrorResponse struct on non-200 responses" do
Req.Test.stub(BraveSearch.API, fn conn ->
conn
|> Plug.Conn.put_resp_content_type("application/json")
|> Plug.Conn.send_resp(429, ~s({"error":"rate_limited"}))
end)
assert {:error, %{"error" => "rate_limited"}} =
assert {:error, %BraveSearch.API.ErrorResponse{status: 429, kind: :rate_limit}} =
BraveSearch.search_images("too many requests")
end
end