Improve exception handling in HostBlocker

In on_config_changed, we now ignore FileNotFoundError as that's a common
occurence and not something worth logging.

In case of other OSError's we now also log the exact error message.
This commit is contained in:
Florian Bruhin 2016-05-07 23:30:32 +02:00
parent f6544786c1
commit b6add69705

View File

@ -276,8 +276,10 @@ class HostBlocker:
if urls is None:
try:
os.remove(self._local_hosts_file)
except OSError:
log.misc.exception("Failed to delete hosts file.")
except FileNotFoundError:
pass
except OSError as e:
log.misc.exception("Failed to delete hosts file: {}".format(e))
def on_download_finished(self, download):
"""Check if all downloads are finished and if so, trigger reading.