Add error handling for migration failure (#23383)

This commit is contained in:
Jason Hu 2019-04-25 12:58:10 -07:00 committed by Paulus Schoutsen
parent 4816a24b3c
commit 7e8f2d72b6
1 changed files with 6 additions and 2 deletions

View File

@ -398,8 +398,12 @@ def process_ha_config_upgrade(hass: HomeAssistant) -> None:
if TTS_PRE_92 in config_raw:
_LOGGER.info("Migrating google tts to google_translate tts")
config_raw = config_raw.replace(TTS_PRE_92, TTS_92)
with open(config_path, 'wt', encoding='utf-8') as config_file:
config_file.write(config_raw)
try:
with open(config_path, 'wt', encoding='utf-8') as config_file:
config_file.write(config_raw)
except IOError:
_LOGGER.exception("Migrating to google_translate tts failed")
pass
with open(version_path, 'wt') as outp:
outp.write(__version__)