mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 20:40:17 +02:00
Added error handling when fetching from GitLab API
This commit is contained in:
parent
363e18e15d
commit
03305c72c7
@ -156,14 +156,26 @@ def _latests_versions(tags: list) -> tuple:
|
|||||||
|
|
||||||
|
|
||||||
def _fetch_list_from_gitlab(url: str, max_pages: int = MAX_PAGES) -> list:
|
def _fetch_list_from_gitlab(url: str, max_pages: int = MAX_PAGES) -> list:
|
||||||
"""returns a list from the GitLab API. Supports pageing"""
|
"""returns a list from the GitLab API. Supports paging"""
|
||||||
result = list()
|
result = list()
|
||||||
|
|
||||||
for page in range(1, max_pages + 1):
|
for page in range(1, max_pages + 1):
|
||||||
|
try:
|
||||||
request = requests.get(
|
request = requests.get(
|
||||||
url, params={'page': page}, timeout=REQUESTS_TIMEOUT
|
url, params={'page': page}, timeout=REQUESTS_TIMEOUT
|
||||||
)
|
)
|
||||||
request.raise_for_status()
|
except requests.exceptions.RequestException as e:
|
||||||
|
error_str = str(e)
|
||||||
|
|
||||||
|
logger.error(
|
||||||
|
f'Unable to fetch from GitLab API. Error: {error_str}',
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
result += request.json()
|
result += request.json()
|
||||||
|
|
||||||
if 'x-total-pages' in request.headers:
|
if 'x-total-pages' in request.headers:
|
||||||
try:
|
try:
|
||||||
total_pages = int(request.headers['x-total-pages'])
|
total_pages = int(request.headers['x-total-pages'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user