From b6add69705bfe8389feb6c73c4cdc22afe9c29e9 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 7 May 2016 23:30:32 +0200 Subject: [PATCH] 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. --- qutebrowser/browser/adblock.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qutebrowser/browser/adblock.py b/qutebrowser/browser/adblock.py index e6d1eab76..55218bf27 100644 --- a/qutebrowser/browser/adblock.py +++ b/qutebrowser/browser/adblock.py @@ -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.