onError method
Called when an exception was occurred during the request.
Implementation
@override
void onError(DioException err, ErrorInterceptorHandler handler) {
// Log the cURL representation of the request when an error occurs.
_logCurlRepresentation(err.requestOptions, isError: true);
// Pass the error to the next handler in the chain.
handler.next(err);
}