handleError static method

dynamic handleError(
  1. DioException error
)

Implementation

static handleError(DioException error) {
  switch (error.type) {
    case DioExceptionType.connectionTimeout:
    case DioExceptionType.sendTimeout:
    case DioExceptionType.receiveTimeout:
      Get.snackbar('Error', 'Connection timeout');
      break;
    case DioExceptionType.badResponse:
      handleResponseError(error.response?.statusCode);
      break;
    default:
      Get.snackbar('Error', 'Something went wrong');
  }
}