From 1781d0fba3e2d79bff4d2bdba45312991e266f14 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 23 Jul 2016 11:21:27 -0400 Subject: [PATCH] Use DoesNotExistError rather than CommandError in get_by_qurl --- qutebrowser/browser/commands.py | 5 ++++- qutebrowser/browser/urlmarks.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index f80bcad9e..d7cbd6a3e 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1110,7 +1110,10 @@ class CommandDispatcher: quickmark_manager = objreg.get('quickmark-manager') if name is None: url = self._current_url() - name = quickmark_manager.get_by_qurl(url) + try: + name = quickmark_manager.get_by_qurl(url) + except urlmarks.DoesNotExistError as e: + raise cmdexc.CommandError(str(e)) try: quickmark_manager.delete(name) except KeyError: diff --git a/qutebrowser/browser/urlmarks.py b/qutebrowser/browser/urlmarks.py index caabf72fa..bfa26d12b 100644 --- a/qutebrowser/browser/urlmarks.py +++ b/qutebrowser/browser/urlmarks.py @@ -34,7 +34,7 @@ from PyQt5.QtCore import pyqtSignal, QUrl, QObject from qutebrowser.utils import (message, usertypes, qtutils, urlutils, standarddir, objreg) -from qutebrowser.commands import cmdexc, cmdutils +from qutebrowser.commands import cmdutils from qutebrowser.misc import lineparser @@ -218,7 +218,7 @@ class QuickmarkManager(UrlMarkManager): index = list(self.marks.values()).index(urlstr) key = list(self.marks.keys())[index] except ValueError: - raise cmdexc.CommandError( + raise DoesNotExistError( "Quickmark for '{}' not found!".format(urlstr)) return key