Skip to content

Commit

Permalink
fix: Use requests.exception.JSONDecodeError in try/except for billing…
Browse files Browse the repository at this point in the history
… service errors (#21907)

silence mypy error about exception not existing
  • Loading branch information
xrdt authored Apr 26, 2024
1 parent e24d18e commit d785d8c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ee/billing/billing_manager.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import json
from datetime import datetime, timedelta
from typing import Any, Optional, cast

import jwt
import requests
import structlog
from django.utils import timezone
from requests import JSONDecodeError # type: ignore[attr-defined]
from rest_framework.exceptions import NotAuthenticated
from sentry_sdk import capture_exception

Expand Down Expand Up @@ -48,7 +48,7 @@ def handle_billing_service_error(res: requests.Response, valid_codes=(200, 404,
try:
response = res.json()
raise Exception(f"Billing service returned bad status code: {res.status_code}", f"body:", response)
except json.decoder.JSONDecodeError:
except JSONDecodeError:
raise Exception(f"Billing service returned bad status code: {res.status_code}", f"body:", res.text)


Expand Down

0 comments on commit d785d8c

Please sign in to comment.