DioExceptions.fromDioError constructor
DioExceptions.fromDioError(
- DioError dioError
Implementation
DioExceptions.fromDioError(DioError dioError) {
switch (dioError.type) {
case DioErrorType.cancel:
message = "Request to API server was cancelled";
break;
case DioErrorType.connectTimeout:
message = "Connection timeout with API server";
break;
case DioErrorType.other:
message = "Connection to API server failed due to internet connection";
break;
case DioErrorType.receiveTimeout:
message = "Receive timeout in connection with API server";
break;
case DioErrorType.response:
errorCode = dioError.response!.statusCode.toString();
message = dioError.response!.statusMessage!;
_handleError(int.tryParse(errorCode.toString()), message);
break;
case DioErrorType.sendTimeout:
message = "Send timeout in connection with API server";
break;
default:
message = "Something went wrong";
break;
}
}