diff --git a/anki/hooks.py b/anki/hooks.py index 78b613402..622112c0b 100644 --- a/anki/hooks.py +++ b/anki/hooks.py @@ -25,13 +25,21 @@ def runHook(hook, *args): hook = _hooks.get(hook, None) if hook: for func in hook: - func(*args) + try: + func(*args) + except: + hook.remove(func) + raise def runFilter(hook, arg, *args): hook = _hooks.get(hook, None) if hook: for func in hook: - arg = func(arg, *args) + try: + arg = func(arg, *args) + except: + hook.remove(func) + raise return arg def addHook(hook, func): diff --git a/aqt/main.py b/aqt/main.py index ad46177d0..a3882fb6b 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -1054,7 +1054,17 @@ will be lost. Continue?""")) showText(ret) else: tooltip(ret) - self.reset() + + # if an error has directed the user to check the database, + # silently clean up any broken reset hooks which distract from + # the underlying issue + while True: + try: + self.reset() + break + except Exception as e: + print("swallowed exception in reset hook:", e) + continue return ret def onCheckMediaDB(self):