DioException.fromDioError constructor

DioException.fromDioError(
  1. DioError dioError
)

Implementation

DioException.fromDioError(DioError dioError) {
  switch (dioError.type) {
    case DioErrorType.cancel:
      message = "Request to API server was cancelled";
      break;
    case DioErrorType.connectionTimeout:
      message = "Connection timeout with API server";
      break;
    case DioErrorType.connectionError:
      message = "Connection to API server failed due to network connection";
      break;
    case DioErrorType.receiveTimeout:
      message = "Receive timeout in connection with API server";
      break;
    case DioErrorType.badResponse:
      message = _handleError(dioError);
      break;
    case DioErrorType.sendTimeout:
      message = "Send timeout in connection with API server";
      break;
    case DioErrorType.unknown:
      message =  "Please check your network connection";
      break;
    default:
      message = "Something went wrong, try again";
      break;
  }
}