HttpClientError.ts
HttpClientError.ts overview
Section titled “HttpClientError.ts overview”Typed failure model for Effect HTTP client operations.
HTTP clients wrap request construction, transport, status-code validation, and
response decoding failures in HttpClientError. The wrapper keeps the failed
request and the specific failure reason together, so callers can handle client
failures uniformly while still matching on the reason _tag for retry
policy, logging, metrics, and user-facing messages.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”errors
Section titled “errors”DecodeError (class)
Section titled “DecodeError (class)”Response error for failures while decoding an HTTP response body.
Signature
declare class DecodeErrorSince v4.0.0
EmptyBodyError (class)
Section titled “EmptyBodyError (class)”Response error for operations that expected a response body but received an empty body.
Signature
declare class EmptyBodyErrorSince v4.0.0
EncodeError (class)
Section titled “EncodeError (class)”Error describing failures while encoding an HTTP request body.
Signature
declare class EncodeErrorSince v4.0.0
HttpClientError (class)
Section titled “HttpClientError (class)”Error wrapper for HTTP client failures, exposing the failed request and the optional response through its reason.
Signature
declare class HttpClientError { constructor(props: { readonly reason: HttpClientErrorReason })}Since v4.0.0
[TypeId] (property)
Section titled “[TypeId] (property)”Marks this value as an HTTP client error for runtime guards.
Signature
readonly [TypeId]: "~effect/http/HttpClientError"Since v4.0.0
HttpClientErrorReason (type alias)
Section titled “HttpClientErrorReason (type alias)”Union of all specific failure reasons carried by HttpClientError.
Signature
type HttpClientErrorReason = RequestError | ResponseErrorSince v4.0.0
InvalidUrlError (class)
Section titled “InvalidUrlError (class)”Error describing failures while constructing a URL from an HTTP client request.
Signature
declare class InvalidUrlErrorSince v4.0.0
RequestError (type alias)
Section titled “RequestError (type alias)”Union of HTTP client errors that occur before a response is available.
Signature
type RequestError = TransportError | EncodeError | InvalidUrlErrorSince v4.0.0
ResponseError (type alias)
Section titled “ResponseError (type alias)”Union of HTTP client errors that include an HTTP response.
Signature
type ResponseError = StatusCodeError | DecodeError | EmptyBodyErrorSince v4.0.0
StatusCodeError (class)
Section titled “StatusCodeError (class)”Response error for HTTP responses rejected because of their status code.
Signature
declare class StatusCodeErrorSince v4.0.0
TransportError (class)
Section titled “TransportError (class)”Error describing transport-level failures that occur while sending an HTTP request.
Signature
declare class TransportErrorSince v4.0.0
guards
Section titled “guards”isHttpClientError
Section titled “isHttpClientError”Returns true when a value is an HttpClientError.
Signature
declare const isHttpClientError: (u: unknown) => u is HttpClientErrorSince v4.0.0
schemas
Section titled “schemas”HttpClientErrorSchema (class)
Section titled “HttpClientErrorSchema (class)”Schema for serializable HTTP client errors, preserving the specific error kind and cause.
Signature
declare class HttpClientErrorSchemaSince v4.0.0
fromHttpClientError (static method)
Section titled “fromHttpClientError (static method)”Builds the serializable schema representation for an HTTP client error.
Signature
declare const fromHttpClientError: (error: HttpClientError) => HttpClientErrorSchemaSince v4.0.0