-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
Suppress logging stack trace on stable build for HomeAssistantError #101762
Conversation
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.
LGTM, thanks @jbouwh 👍
This is quite a big change, before we merge I'd like:
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Thnx @MartinHjelmare , I'll prepare a blog post |
That is an alternative approach. We catch the expected errors in |
If we have places where we print traces for these exceptions, that is a bug. We should find those places and fix them, not hide it globally. |
Secondly, if we are interested in the traces we could print traces if debug level logging is on for that specific location where we caught the exception. Again this need to be done where we catch the exception. |
Just to be clear: This PR is not effecting stack traces for unexpected exceptions. |
Right, and i say that any place that prints traces for these exceptions are faulty. |
Okay, all we are effectively doing here is suppressing track prints on known catched errors. All other errors can be assumed caused by bugs, will have a stack trace and should be fixed indeed. |
Secondly, to still allow developers to solve caught exceptions, stack traces are still unfiltered for know errors. |
Drafting so we make sure we're aligned on the next step before going ahead. |
The implementation is changing, and there's an open architecture issue -> I requested a new review from myself and @MartinHjelmare |
Co-authored-by: Martin Hjelmare <[email protected]>
314ca35
to
c5e2f7d
Compare
Superseeded by #102410 |
Proposed change
Suppress stack traces on logs raised with HomeAssistantError on stable versions of HomeAssistant and when debug logging is abled (for a specific logger).
Rationale
HomeAssistantError
and its subclasses are expected errors which means a stack trace is not warranted. Printing a stack trace is still very helpful during development though. The solution in the PR avoids spamming users with stack traces, while also not obstructing development.We make it possible to enable logging stack trace for
HomeAssistantError
also on stable builds when debug level is supported by the logger.Architectural discussion: home-assistant/architecture#986
Type of change
Additional information
Checklist
black --fast 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
..coveragerc
.To help with the load of incoming pull requests: