HttpErrorUnion

PackageAxial.HttpClient

HttpError

HttpError is the single typed error of Axial.HttpClient. Every request that cannot produce its expected value fails with one case of this union, so callers handle one error type instead of catching exceptions. Interrupting the workflow is not a case here: an interrupted request ends with Cause.Interrupt, never an HttpError.

The union

Case Raised when
InvalidRequest message The request could not be constructed, for example from a malformed URL.
ConnectionFailed (request, message) The connection could not be established or was dropped before a response arrived.
TimedOut (request, timeout) The per-request timeout elapsed before the response completed.
Status response The response arrived with a status outside the request's expectation; the full transcript is carried.
DecodeFailed (message, response) The response body could not be decoded into the requested value; the full transcript is carried.
ResponseTooLarge (request, limit) The response body exceeded the request's maxResponseBytes limit, so it was not read.

ConnectionFailed, TimedOut, and ResponseTooLarge carry a redacted request line; Status and DecodeFailed carry the full HttpResponse transcript so an error handler can log the offending payload without re-fetching it.

Module helpers

  • HttpError.describe error formats any case with its redacted request context and a bounded body preview, so a single Flow.mapError HttpError.describe produces loggable messages.
  • HttpError.tryResponse error extracts the transcript from the cases that carry one (Status and DecodeFailed).
  • HttpError.isTransient error classifies exactly the failures where a retry can help: connection failures, timeouts, and 408/429/5xx statuses.
  • HttpError.transientRetry retries baseDelay builds a Schedule that retries only transient errors, with exponential backoff from baseDelay capped at 65536 times it. retries counts retries after the first attempt.

Read the responses and errors guide for a response walkthrough and reliability for timeouts and retries.

Specification

Kind
Union
Members
16
Examples
0
describeSignature
HttpError.describe error
tryResponseSignature
HttpError.tryResponse _arg1
isTransientSignature
HttpError.isTransient _arg1
transientRetrySignature
HttpError.transientRetry retries baseDelay
IsStatusSignature
this.IsStatus

Summary

NameSignatureSynopsis
Union cases
IsStatusthis.IsStatusNo description available.
IsInvalidRequestthis.IsInvalidRequestNo description available.
IsTimedOutthis.IsTimedOutNo description available.
IsDecodeFailedthis.IsDecodeFailedNo description available.
IsConnectionFailedthis.IsConnectionFailedNo description available.
IsResponseTooLargethis.IsResponseTooLargeNo description available.
InvalidRequestInvalidRequest messageThe request could not be constructed, for example from a malformed URL.
ConnectionFailedConnectionFailed(request, message)The connection could not be established or was dropped before a response arrived.
TimedOutTimedOut(request, timeout)The per-request timeout elapsed before the response completed.
StatusStatus responseThe response arrived with a status outside the request's expectation.
DecodeFailedDecodeFailed(message, response)The response body could not be decoded into the requested value.
ResponseTooLargeResponseTooLarge(request, limit)The response body exceeded the request's <c>Request.maxResponseBytes</c> limit, so it was not read.
Operations
describeHttpError.describe errorFormats an HTTP error with its redacted request context.
tryResponseHttpError.tryResponse _arg1Returns the response transcript when the error carries one.
isTransientHttpError.isTransient _arg1Indicates whether retrying the same request could plausibly succeed.
transientRetryHttpError.transientRetry retries baseDelayBuilds a schedule that retries only transient HTTP errors, with exponential backoff from <paramref name="baseDelay" /> capped at 65536 times it.

Union cases

kind:member

IsStatus

this.IsStatus
Member

Returns

bool
kind:member

IsInvalidRequest

this.IsInvalidRequest
Member

Returns

bool
kind:member

IsTimedOut

this.IsTimedOut
Member

Returns

bool
kind:member

IsDecodeFailed

this.IsDecodeFailed
Member

Returns

bool
kind:member

IsConnectionFailed

this.IsConnectionFailed
Member

Returns

bool
kind:member

IsResponseTooLarge

this.IsResponseTooLarge
Member

Returns

bool
kind:member

InvalidRequest

InvalidRequest message
Member
The request could not be constructed, for example from a malformed URL.

Parameters

NameTypeDescription
messagestring

Returns

unit
kind:member

ConnectionFailed

ConnectionFailed(request, message)
Member
The connection could not be established or was dropped before a response arrived.

Parameters

NameTypeDescription
requeststring
messagestring

Returns

unit
kind:member

TimedOut

TimedOut(request, timeout)
Member
The per-request timeout elapsed before the response completed.

Parameters

NameTypeDescription
requeststring
timeoutTimeSpan

Returns

unit
kind:member

Status

Status response
Member
The response arrived with a status outside the request's expectation.

Parameters

NameTypeDescription
responseHttpResponse

Returns

unit
kind:member

DecodeFailed

DecodeFailed(message, response)
Member
The response body could not be decoded into the requested value.

Parameters

NameTypeDescription
messagestring
responseHttpResponse

Returns

unit
kind:member

ResponseTooLarge

ResponseTooLarge(request, limit)
Member
The response body exceeded the request's <c>Request.maxResponseBytes</c> limit, so it was not read.

Parameters

NameTypeDescription
requeststring
limitint64

Returns

unit

Operations

kind:member

describe

HttpError.describe error
Member
Formats an HTTP error with its redacted request context. <example><code>error |&gt; HttpError.describe</code></example>

Parameters

NameTypeDescription
errorHttpError

Returns

string
kind:member

tryResponse

HttpError.tryResponse _arg1
Member
Returns the response transcript when the error carries one. <example><code>HttpError.tryResponse error</code></example>

Parameters

NameTypeDescription
_arg1HttpError

Returns

HttpResponse option
kind:member

isTransient

HttpError.isTransient _arg1
Member
Indicates whether retrying the same request could plausibly succeed. Connection failures, timeouts, and 408/429/5xx statuses are transient. <example><code>if HttpError.isTransient error then retry ()</code></example>

Parameters

NameTypeDescription
_arg1HttpError

Returns

bool
kind:member

transientRetry

HttpError.transientRetry retries baseDelay
Member
Builds a schedule that retries only transient HTTP errors, with exponential backoff from <paramref name="baseDelay" /> capped at 65536 times it. <paramref name="retries" /> counts retries after the first attempt. <example><code>workflow |&gt; Flow.retry (HttpError.transientRetry 3 (TimeSpan.FromMilliseconds 200.0))</code></example>

Parameters

NameTypeDescription
retriesint
baseDelayTimeSpan

Returns

Schedule<'env, HttpError, int>