mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Log the reason a config entry failed to setup (#48449)
If we pass a string to ConfigEntryNotReady or raise it from another exception we now log the string passed or the string generated by the original exception. With #47201 this makes it easy for developers to still show the reason why setup failed without having to worry about log spam from additional attempts by rasing ConfigEntryNotReady from the original exception.
This commit is contained in:
@@ -252,21 +252,27 @@ class ConfigEntry:
|
||||
"%s.async_setup_entry did not return boolean", integration.domain
|
||||
)
|
||||
result = False
|
||||
except ConfigEntryNotReady:
|
||||
except ConfigEntryNotReady as ex:
|
||||
self.state = ENTRY_STATE_SETUP_RETRY
|
||||
wait_time = 2 ** min(tries, 4) * 5
|
||||
tries += 1
|
||||
message = str(ex)
|
||||
if not message and ex.__cause__:
|
||||
message = str(ex.__cause__)
|
||||
ready_message = f"ready yet: {message}" if message else "ready yet"
|
||||
if tries == 1:
|
||||
_LOGGER.warning(
|
||||
"Config entry '%s' for %s integration not ready yet. Retrying in background",
|
||||
"Config entry '%s' for %s integration not %s; Retrying in background",
|
||||
self.title,
|
||||
self.domain,
|
||||
ready_message,
|
||||
)
|
||||
else:
|
||||
_LOGGER.debug(
|
||||
"Config entry '%s' for %s integration not ready yet. Retrying in %d seconds",
|
||||
"Config entry '%s' for %s integration not %s; Retrying in %d seconds",
|
||||
self.title,
|
||||
self.domain,
|
||||
ready_message,
|
||||
wait_time,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user