DioExceptions.fromDioError constructor

DioExceptions.fromDioError({
  1. required DioException dioError,
})

Implementation

DioExceptions.fromDioError({required DioException dioError}) {
  switch (dioError.type) {
    case DioExceptionType.cancel:
      message = "Request to API server was cancelled";
      break;
    case DioExceptionType.connectionTimeout:
      message = "Connection timeout with API server";
      break;
    case DioExceptionType.receiveTimeout:
      message = "Receive timeout in connection with API server";
      break;
    case DioExceptionType.badResponse:
      message = _handleError(dioError.response!.statusCode!, dioError.response!.data);
      break;
    case DioExceptionType.sendTimeout:
      message = "Send timeout in connection with API server";
      break;
    default:
      message = "Something went wrong";
      break;
  }
}