DioExceptionHandling.fromDioError constructor

DioExceptionHandling.fromDioError(
  1. DioException dioError
)

Implementation

DioExceptionHandling.fromDioError(DioException dioError) {
  switch (dioError.error) {
    case DioExceptionType.cancel:
      errorMessage = 'Request to the server was cancelled.';
      break;
    case DioExceptionType.connectionTimeout:
      errorMessage = 'Connection timed out.';
      break;
    case DioExceptionType.receiveTimeout:
      errorMessage = 'Receiving timeout occurred.';
      break;
    case DioExceptionType.sendTimeout:
      errorMessage = 'Request send timeout.';
      break;
    default:
      errorMessage = 'Something went wrong';
      break;
  }
  CommonWidgets.toast(message: errorMessage);
}