A nicer error message when a no longer existing link is activated

This commit is contained in:
Kovid Goyal 2013-12-14 09:13:40 +05:30
parent 8fc809ae0c
commit 6a4d56c839

View File

@ -710,7 +710,14 @@ class Boss(QObject):
editor = editors[name] editor = editors[name]
self.gui.central.show_editor(editor) self.gui.central.show_editor(editor)
else: 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) editor = self.edit_file(name, syntax)
if anchor: if anchor:
editor.go_to_anchor(anchor) editor.go_to_anchor(anchor)