You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update client_v2.py with handling JSON Decode error
## What
This PR improves error handling in the `LLMWhispererClientV2.whisper_status` function.
The update ensures empty or non-JSON API responses are handled gracefully: errors are now logged using `self.logger` and clear, actionable exceptions are raised, preventing uninformative or misleading `JSONDecodeError` stack traces.
## Why
Previously, when the API failed and returned an empty or malformed response, the client attempted to parse it as JSON, resulting in cryptic errors and poor diagnostics for downstream consumers.
This change makes error messages clear and actionable, improving maintainability and debuggability for both developers and users.
## How
- Adds a defensive check for empty (`None` or blank) response bodies.
- Wraps `json.loads(response.text)` in a try/except; logs errors and response content with `self.logger`.
- Raises `LLMWhispererClientException` using the correct constructor signature (`value, status_code`).
- All raised exceptions now include the original status code and a clear error message.
## Relevant Docs
N/A
## Related Issues or PRs
- Fixes: LW-158
## Notes on Testing
- Manually simulated API failures with empty and non-JSON responses to verify clear logging and correct exception behavior.
- Ensured that all existing integration tests for client error handling continue to pass.
## Checklist
I have read and understood the [Contribution Guidelines]().
Signed-off-by: ali <[email protected]>
0 commit comments