From 6a4d56c839a8ab5c927e9592f5282edc04df7b3e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 14 Dec 2013 09:13:40 +0530 Subject: [PATCH] A nicer error message when a no longer existing link is activated --- src/calibre/gui2/tweak_book/boss.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 703255d8c5..c12050192f 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -710,7 +710,14 @@ class Boss(QObject): editor = editors[name] self.gui.central.show_editor(editor) else: - syntax = syntax_from_mime(name, current_container().mime_map[name]) + try: + mt = current_container().mime_map[name] + except KeyError: + return error_dialog(self.gui, _('Does not exist'), _( + 'The file %s does not exist. If you were trying to click a' + ' link in the preview panel or the Table of Contents, you may' + ' need to refresh them by right-clicking and choosing "Refresh".') % name, show=True) + syntax = syntax_from_mime(name, mt) editor = self.edit_file(name, syntax) if anchor: editor.go_to_anchor(anchor)