Skip to content

Commit 44e020b

Browse files
committed
[CHANGE] Attempting to catch ESI errors thrown by aiopenapi3
See: https://gitlab.com/allianceauth/django-esi/-/issues/40
1 parent a960f63 commit 44e020b

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ Section Order:
4141
### Security
4242
-->
4343

44+
### Changed
45+
46+
- Attempting to catch ESI errors thrown by the OpenAPI client through `aiopenapi3` (See: https://gitlab.com/allianceauth/django-esi/-/issues/40)
47+
4448
## [3.0.0-alpha.2] - 2025-09-04
4549

4650
> [!CAUTION]

‎sovtimer/models.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
Our Models
33
"""
44

5+
# Third Party
6+
from aiopenapi3 import ContentTypeError
7+
58
# Django
69
from django.db import models
710
from django.utils.translation import gettext_lazy as _
@@ -86,10 +89,10 @@ def get_sov_structures_from_esi(cls):
8689
sovereignty_structures_esi = (
8790
esi.client.Sovereignty.GetSovereigntyStructures().results()
8891
)
89-
except OSError as ex:
92+
except (OSError, ContentTypeError) as ex:
9093
logger.info(
9194
msg=(
92-
f"Something went wrong while trying to fetch sovereignty structures from ESI: {ex}"
95+
f"Error while trying to fetch sovereignty structures from ESI: {ex}"
9396
)
9497
)
9598
sovereignty_structures_esi = None
@@ -150,10 +153,10 @@ def get_sov_campaigns_from_esi(cls):
150153
sovereignty_campaigns_esi = (
151154
esi.client.Sovereignty.GetSovereigntyCampaigns().results()
152155
)
153-
except OSError as ex:
156+
except (OSError, ContentTypeError) as ex:
154157
logger.info(
155158
msg=(
156-
f"Something went wrong while trying to fetch sovereignty campaigns from ESI: {ex}"
159+
f"Error while trying to fetch sovereignty campaigns from ESI: {ex}"
157160
)
158161
)
159162
sovereignty_campaigns_esi = None

‎sovtimer/tasks.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def update_sov_campaigns() -> None:
9595
)
9696

9797
if not campaigns_from_esi:
98-
logger.info(msg="No sovereignty campaigns found, nothing to update.")
98+
logger.info(msg="No (new) sovereignty campaigns found, nothing to update.")
9999

100100
return
101101

@@ -171,7 +171,7 @@ def update_sov_structures() -> None:
171171

172172
# If no structures are returned from ESI, we can exit early
173173
if not structures_from_esi:
174-
logger.info(msg="No sovereignty structures found, nothing to update.")
174+
logger.info(msg="No (new) sovereignty structures found, nothing to update.")
175175

176176
return
177177

0 commit comments

Comments
 (0)