getErrorResponse function

ApiResults getErrorResponse(
  1. DioExceptionType type,
  2. dynamic data
)

Implementation

ApiResults getErrorResponse(DioExceptionType type, dynamic data) {
  switch (type) {
    case DioExceptionType.connectionTimeout:
      return ApiResults(data, 0, strAppConnectionTimeout);

    case DioExceptionType.receiveTimeout:
      return ApiResults(data, 0, strAppRequestTimeout);

    case DioExceptionType.badCertificate:
      return ApiResults(data, 0, strAppSomethingWentWrong);

    case DioExceptionType.badResponse:
      return ApiResults(data, 0, strAppSomethingWentWrong);

    case DioExceptionType.cancel:
      return ApiResults(data, 0, strAppConnectionCancelled);

    case DioExceptionType.connectionError:
      return ApiResults(data, 0, strAppConnectionFailed);

    case DioExceptionType.unknown:
      return ApiResults(data, 0, strAppNoInternet);

    case DioExceptionType.sendTimeout:
      return ApiResults(data, 0, strAppSomethingWentWrong);
  }
}