mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
http(request): collates status checks
This commit is contained in:
parent
605f878f9b
commit
02350c924b
1 changed files with 4 additions and 6 deletions
|
|
@ -257,12 +257,6 @@ async def request(
|
||||||
# some other error, will be handled later on
|
# some other error, will be handled later on
|
||||||
break
|
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
|
# See https://github.com/kennethreitz/requests/issues/2042
|
||||||
content_type = response.headers.get("Content-Type", "")
|
content_type = response.headers.get("Content-Type", "")
|
||||||
if (
|
if (
|
||||||
|
|
@ -281,10 +275,14 @@ async def request(
|
||||||
# https://github.com/pimutils/vdirsyncer/issues/1186
|
# https://github.com/pimutils/vdirsyncer/issues/1186
|
||||||
logger.debug(await response.text())
|
logger.debug(await response.text())
|
||||||
|
|
||||||
|
if response.status == 403 and await _is_quota_exceeded_google(response):
|
||||||
|
raise UsageLimitReached(response.reason)
|
||||||
if response.status == 412:
|
if response.status == 412:
|
||||||
raise exceptions.PreconditionFailed(response.reason)
|
raise exceptions.PreconditionFailed(response.reason)
|
||||||
if response.status in (404, 410):
|
if response.status in (404, 410):
|
||||||
raise exceptions.NotFoundError(response.reason)
|
raise exceptions.NotFoundError(response.reason)
|
||||||
|
if response.status == 429:
|
||||||
|
raise UsageLimitReached(response.reason)
|
||||||
|
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response
|
return response
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue