Add error handling for HTTP requests in import_chzzk_campaign command and enhance pagination display in campaign list template
All checks were successful
Deploy to Server / deploy (push) Successful in 21s

This commit is contained in:
Joakim Hellsén 2026-04-01 04:32:42 +02:00
commit 4b04659fce
Signed by: Joakim Hellsén
SSH key fingerprint: SHA256:/9h/CsExpFp+PRhsfA0xznFx2CGfTT5R/kpuFfUgEQk
2 changed files with 16 additions and 2 deletions

View file

@ -52,7 +52,17 @@ class Command(BaseCommand):
"User-Agent": USER_AGENT,
},
)
resp.raise_for_status()
try:
resp.raise_for_status()
except requests.HTTPError as e:
json_msg: str = ""
if resp.headers.get("Content-Type", "").startswith("application/json"):
error_data = resp.json()
json_msg = error_data.get("message", "")
msg: str = f"Failed to fetch campaign {campaign_no}: {e} - {json_msg}"
self.stdout.write(self.style.ERROR(msg))
return
data: dict[str, Any] = resp.json()
campaign_data: ChzzkCampaignV2