Package: @effect/ai
Module: AiError
Error that occurs during HTTP response processing.
This error is thrown when issues arise after receiving an HTTP response, such as unexpected status codes, response decoding failures, or empty response bodies.
Example
import { AiError } from "@effect/ai"
import { Option } from "effect"
const responseError = new AiError.HttpResponseError({
module: "OpenAI",
method: "createCompletion",
reason: "StatusCode",
request: {
method: "POST",
url: "https://api.openai.com/v1/completions",
urlParams: [],
hash: Option.none(),
headers: { "Content-Type": "application/json" }
},
response: {
status: 429,
headers: { "X-RateLimit-Remaining": "0" }
},
description: "Rate limit exceeded"
})
console.log(responseError.message)
// "StatusCode: Rate limit exceeded (429 POST https://api.openai.com/v1/completions)"
Signature
declare class HttpResponseError
Since v1.0.0