handleExceptions method
Handles exceptions that occur during the request.
Implementation
Future<http.Response> handleExceptions({
final Duration timeout = const Duration(seconds: 30),
}) {
return this
.timeout(
timeout,
onTimeout: () => http.Response.bytes(
[],
408,
reasonPhrase: 'Timed out after ${timeout.inSeconds} seconds',
),
)
.catchError(
(e) => http.Response.bytes(
[],
500,
reasonPhrase: e.toString(),
),
);
}