Skip to content

Commit f98126d

Browse files
author
Jens Kürten
committed
catch rate limit exceeded
1 parent e7ffaf3 commit f98126d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

csfunctions/service/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class UnprocessableEntity(Exception):
2121
pass
2222

2323

24+
class RateLimitExceeded(Exception):
25+
pass
26+
27+
2428
class BaseService:
2529
"""
2630
Base class for services.
@@ -54,6 +58,8 @@ def request(
5458
raise NotFound
5559
elif response.status_code == 422:
5660
raise UnprocessableEntity(response.text)
61+
elif response.status_code == 429:
62+
raise RateLimitExceeded(response.text)
5763
if response.status_code == 200:
5864
return response.json()
5965
else:

csfunctions/service/file_upload.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def upload_file_content(
146146
csfunctions.service.Unauthorized: If access check fails.
147147
csfunctions.service.Conflict: If the file is already locked.
148148
csfunctions.service.NotFound: If the file object does not exist.
149+
csfunctions.service.RateLimitExceeded: If the services rate limit is exceeded.
149150
"""
150151
persno = persno or self.metadata.app_user
151152
if filesize is None:
@@ -206,6 +207,7 @@ def upload_new_file(
206207
Raises:
207208
csfunctions.service.Unauthorized: If access check fails.
208209
csfunctions.service.NotFound: If the parent object does not exist.
210+
csfunctions.service.RateLimitExceeded: If the services rate limit is exceeded.
209211
"""
210212
persno = persno or self.metadata.app_user
211213
file_object_id = self._create_new_file(

0 commit comments

Comments
 (0)