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.receiveTimeout:
      message = 'Receive timeout in connection with API server';
      break;
    case DioErrorType.badResponse:
      message = _handleError(
        dioError.response?.statusCode,
        dioError.response?.data,
      );
      break;
    case DioErrorType.sendTimeout:
      message = 'Send timeout in connection with API server';
      break;
    default:
      message = 'Something went wrong';
      break;
  }
}