HttpTransportException class

Thrown by an HttpTransport when a request got no response at all: the connection could not be opened, it broke, or the request's timeout or readTimeout ran out. In the browser a request blocked by CORS fails this way too.

It is different from an error status: a 500 is a response, this exception means the server's answer never arrived. Such failures are often temporary, so they are worth retrying. Feign clients wrap it in a RetryableException, which a Retryer bean can retry (nothing is retried by default); you catch it yourself only when you call a transport directly.

try {
  await transport.send(request);
} on HttpTransportException catch (error) {
  // A slow server and an unreachable one call for different messages.
  if (error.isTimeout) { ... }
}

Spring (Java): ResourceAccessException, which RestTemplate throws for an I/O error:

catch (ResourceAccessException e) { ... }
Implemented types

Constructors

HttpTransportException(String message, {HttpRequest? request, Object? cause, bool isTimeout = false})
A failure described by message, of request when it is known. cause keeps the platform's own error; set isTimeout when a time limit ran out.

Properties

cause → Object?
The error the platform reported (a SocketException, a TimeoutException, a JavaScript error), or null.
final
hashCode → int
The hash code for this object.
no setterinherited
isTimeout → bool
Whether a time limit ran out: the request's timeout or readTimeout, or the connection timeout of the platform.
final
message → String
What went wrong, for people, such as connection failed: Connection refused or no data within 60000 ms (read timeout).
final
request → HttpRequest?
The request that failed, or null when it is not known.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited