onError method
Error
Implementation
@override
FutureOr<html.HttpRequest> onError(final response) {
final completer = Completer<html.HttpRequest>();
// Process the error response
if (response.target.status != 0) {
try {
final dynamic errorAsJson =
jsonobject.JsonObjectLite<dynamic>.fromJsonString(
response.target.responseText);
generateErrorResponse(errorAsJson, response.target.status);
allResponseHeaders = response.target.getAllResponseHeaders();
completer.complete(response.target);
return completer.future;
} on Exception {
final dynamic errorAsJson = jsonobject.JsonObjectLite<dynamic>();
errorAsJson.message = 'JSON Decode failure';
generateErrorResponse(errorAsJson, response.target.status);
allResponseHeaders = response.target.getAllResponseHeaders();
completer.complete(response.target);
return completer.future;
}
} else {
final dynamic errorAsJson = jsonobject.JsonObjectLite<dynamic>();
generateErrorResponse(errorAsJson, response.target.status);
completer.complete(response.target);
return completer.future;
}
}