-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Add translation of exceptions in met #155765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
Hey there @Danielhiversen, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the Met.no integration to use translatable exceptions following Home Assistant's Gold tier quality scale requirements. The changes replace a custom exception class with Home Assistant's built-in exception classes that support translation keys.
- Removed custom
CannotConnectexception class in favor ofHomeAssistantErrorwith translation support - Added exception translations to
strings.jsonfor user-facing error messages - Updated exception handling to use translation keys and placeholders
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| homeassistant/components/met/strings.json | Adds "exceptions" section with translation keys for cannot_connect and update_failed error messages |
| homeassistant/components/met/coordinator.py | Removes custom CannotConnect exception class and updates exception raising to use HomeAssistantError and UpdateFailed with translation support |
| """Fetch data from Met.""" | ||
| try: | ||
| return await self.weather.fetch_data() | ||
| except Exception as err: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so 2 things
- Ideally we don't catch raw Exceptions outside of the config flow and outside of tasks, so IMO we should just remove this except. This might uncover some bugs like a ValueError or AttributeError, but we should watch for those and properly fix the code
- You're now raising a translated exception to be caught and to be raised again as translated exception, I think we can just do this once
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Breaking change
Proposed change
Ref: https://developers.home-assistant.io/docs/core/integration-quality-scale/rules/exception-translations
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: