Skip to content

Commit 3846d80

Browse files
committed
Use specific exception types in token refresh error handling
- Catch only TokenRefreshError and AuthenticationError instead of Exception - Prevents masking unexpected errors during token refresh - Addresses code review feedback
1 parent 4ed6ece commit 3846d80

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/nwp500/api_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
import aiohttp
1111

12-
from .auth import AuthenticationError, NavienAuthClient
12+
from .auth import (
13+
AuthenticationError,
14+
NavienAuthClient,
15+
TokenRefreshError,
16+
)
1317
from .config import API_BASE_URL
1418
from .models import Device, FirmwareInfo, TOUInfo
1519

@@ -181,7 +185,10 @@ async def _make_request(
181185
params,
182186
retry_on_auth_failure=False,
183187
)
184-
except Exception as refresh_error:
188+
except (
189+
TokenRefreshError,
190+
AuthenticationError,
191+
) as refresh_error:
185192
_logger.error(
186193
f"Token refresh failed: {refresh_error}"
187194
)

0 commit comments

Comments
 (0)