transformApiError method

KakaoException transformApiError (DioError e)

transforms DioError to KakaoException.

Implementation

static KakaoException transformApiError(DioError e) {
  if (e.response == null) return KakaoClientException(e.message);
  if (e.response.statusCode == 404) {
    return KakaoClientException(e.message);
  }
  if (Uri.parse(e.request.baseUrl).host == KakaoContext.hosts.kauth) {
    return KakaoAuthException.fromJson(e.response.data);
  }
  if (Uri.parse(e.request.baseUrl).host == KakaoContext.hosts.dapi) {
    return DapiException.fromJson(e.response.data);
  }

  return KakaoApiException.fromJson(e.response.data);
}