handleResponse static method

NetworkExceptions handleResponse(
  1. int? statusCode
)

Implementation

static NetworkExceptions handleResponse(int? statusCode) {
  switch (statusCode) {
    case 400:
    case 401:
    case 403:
      return const NetworkExceptions.unauthorizedRequest();
    case 404:
      return const NetworkExceptions.notFound("Not found");
    case 409:
      return const NetworkExceptions.conflict();
    case 408:
      return const NetworkExceptions.requestTimeout();
    case 500:
      return const NetworkExceptions.internalServerError();
    case 503:
      return const NetworkExceptions.serviceUnavailable();
    default:
      var responseCode = statusCode;
      return NetworkExceptions.defaultError(
        "Received invalid status code: $responseCode",
      );
  }
}