@@ -3,8 +3,8 @@ import { describe, expect, it } from "vitest";
|
3 | 3 | import { |
4 | 4 | assertOkOrThrowProviderError, |
5 | 5 | assertOkOrThrowHttpError, |
| 6 | +createProviderHttpError, |
6 | 7 | extractProviderErrorDetail, |
7 | | -extractProviderErrorInfo, |
8 | 8 | extractProviderRequestId, |
9 | 9 | ProviderHttpError, |
10 | 10 | readProviderBinaryResponse, |
@@ -124,19 +124,8 @@ describe("provider error utils", () => {
|
124 | 124 | }, |
125 | 125 | ); |
126 | 126 | |
127 | | -const info = await extractProviderErrorInfo(response.clone()); |
128 | | -expect(info).toMatchObject({ |
129 | | -code: "insufficient_quota", |
130 | | -type: "rate_limit_error", |
131 | | -requestId: "req_456", |
132 | | -}); |
133 | | -expect(info.detail).toContain("Quota exceeded"); |
134 | | -expect(info.body).toContain("Quota exceeded"); |
135 | | -expect(info.body).not.toContain("sk-secret1234567890abcd"); |
136 | | - |
137 | | -await expect( |
138 | | -assertOkOrThrowProviderError(response, "Provider API error"), |
139 | | -).rejects.toMatchObject({ |
| 127 | +const error = await createProviderHttpError(response, "Provider API error"); |
| 128 | +expect(error).toMatchObject({ |
140 | 129 | name: "ProviderHttpError", |
141 | 130 | status: 429, |
142 | 131 | statusCode: 429, |
@@ -145,6 +134,10 @@ describe("provider error utils", () => {
|
145 | 134 | errorType: "rate_limit_error", |
146 | 135 | requestId: "req_456", |
147 | 136 | } satisfies Partial<ProviderHttpError>); |
| 137 | +const providerError = error as ProviderHttpError; |
| 138 | +expect(providerError.message).toContain("Quota exceeded"); |
| 139 | +expect(providerError.errorBody).toContain("Quota exceeded"); |
| 140 | +expect(providerError.errorBody).not.toContain("sk-secret1234567890abcd"); |
148 | 141 | }); |
149 | 142 | |
150 | 143 | it("keeps legacy HTTP status formatting while sharing provider parsing", async () => { |
|