From 02350c924b891d43ce75067df4b5609b5d5beda3 Mon Sep 17 00:00:00 2001 From: samm81 Date: Sat, 13 Sep 2025 16:21:01 +0700 Subject: [PATCH] http(request): collates status checks --- vdirsyncer/http.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/vdirsyncer/http.py b/vdirsyncer/http.py index 954e5be..eee0089 100644 --- a/vdirsyncer/http.py +++ b/vdirsyncer/http.py @@ -257,12 +257,6 @@ async def request( # some other error, will be handled later on break - if response.status == 429: - raise UsageLimitReached(response.reason) - - if response.status == 403 and await _is_quota_exceeded_google(response): - raise UsageLimitReached(response.reason) - # See https://github.com/kennethreitz/requests/issues/2042 content_type = response.headers.get("Content-Type", "") if ( @@ -281,10 +275,14 @@ async def request( # https://github.com/pimutils/vdirsyncer/issues/1186 logger.debug(await response.text()) + if response.status == 403 and await _is_quota_exceeded_google(response): + raise UsageLimitReached(response.reason) if response.status == 412: raise exceptions.PreconditionFailed(response.reason) if response.status in (404, 410): raise exceptions.NotFoundError(response.reason) + if response.status == 429: + raise UsageLimitReached(response.reason) response.raise_for_status() return response