MCPcopy Index your code
hub / github.com/anomalyco/opencode / statusError

Function statusError

packages/llm/src/route/executor.ts:278–305  ·  view source on GitHub ↗
(request: HttpClientRequest.HttpClientRequest, redactedNames: ReadonlyArray<string | RegExp>)

Source from the content-addressed store, hash-verified

276
277const statusError =
278 (request: HttpClientRequest.HttpClientRequest, redactedNames: ReadonlyArray<string | RegExp>) =>
279 (response: HttpClientResponse.HttpClientResponse) =>
280 Effect.gen(function* () {
281 if (response.status < 400) return response
282 const body = yield* response.text.pipe(Effect.catch(() => Effect.void))
283 const headers = normalizedHeaders(response.headers)
284 const retryAfter = retryAfterMs(headers)
285 const rateLimit = rateLimitDetails(headers, retryAfter)
286 const details = responseBody(body, request)
287 return yield* new LLMError({
288 module: "RequestExecutor",
289 method: "execute",
290 reason: statusReason({
291 status: response.status,
292 message: providerMessage(response.status, details),
293 retryAfterMs: retryAfter,
294 rateLimit,
295 http: responseHttp({
296 request,
297 response,
298 redactedNames,
299 body: details,
300 requestId: requestId(headers),
301 rateLimit,
302 }),
303 }),
304 })
305 })
306
307const toHttpError = (redactedNames: ReadonlyArray<string | RegExp>) => (error: unknown) => {
308 const transportError = (input: {

Callers 1

executeOnceFunction · 0.85

Calls 8

normalizedHeadersFunction · 0.85
retryAfterMsFunction · 0.85
rateLimitDetailsFunction · 0.85
responseBodyFunction · 0.85
statusReasonFunction · 0.85
providerMessageFunction · 0.85
responseHttpFunction · 0.85
requestIdFunction · 0.85

Tested by

no test coverage detected