handleResponseError static method
String
handleResponseError(
- dynamic error
)
Implementation
static String handleResponseError(dynamic error) {
String errorDescription = "";
if (error is DioError) {
DioError dioError = error;
switch (dioError.type) {
case DioErrorType.connectTimeout:
errorDescription = "Connection timeout with API server";
break;
case DioErrorType.sendTimeout:
errorDescription = "Send timeout in connection with API server";
break;
case DioErrorType.receiveTimeout:
errorDescription = "Receive timeout in connection with API server";
break;
case DioErrorType.response:
errorDescription =
"Received invalid status code: ${dioError.response!.statusCode}";
break;
case DioErrorType.cancel:
errorDescription = "Request to API server was cancelled";
break;
case DioErrorType.other:
errorDescription =
"Connection to API server failed due to internet connection";
break;
}
} else {
errorDescription = "Unexpected error occured";
}
return errorDescription;
}