Skip to content

Refactor generic exception handling (bare except) #889

Description

@ic-dev21

Version of the custom_component

Configuration

N/A

Describe the bug

There are places in the codebase where exception handling is too generic, such as with except Exception or bare except: blocks. This practice can hide unexpected errors and complicate debugging and maintenance.

Below is a concrete example found in the codebase where a generic exception handler is used:


Example: Bare except block in Hilo class

custom_components/hilo/init.py

try:
    ...
except Exception as e:
    LOG.error("Error in websocket handler %s: %s", handler_name, e)
    LOG.error(traceback.format_exc())

Other similar cases may be present in the codebase. Please consider refactoring these blocks to handle only the appropriate exceptions explicitly.


Improving exception handling will make the codebase more robust and easier to debug and maintain.

Debug log

N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions