Handle errors in :dump-page.

This commit is contained in:
Florian Bruhin 2015-11-24 18:03:39 +01:00
parent e405492667
commit b37dac7bfa

View File

@ -1240,8 +1240,13 @@ class CommandDispatcher:
data = mainframe.toPlainText() data = mainframe.toPlainText()
else: else:
data = mainframe.toHtml() data = mainframe.toHtml()
try:
with open(dest, 'w', encoding='utf-8') as f: with open(dest, 'w', encoding='utf-8') as f:
f.write(data) f.write(data)
except OSError as e:
raise cmdexc.CommandError('Could not write page: {}'.format(e))
else:
message.info(self._win_id, "Dumped page to {}.".format(dest)) message.info(self._win_id, "Dumped page to {}.".format(dest))
@cmdutils.register(instance='command-dispatcher', name='help', @cmdutils.register(instance='command-dispatcher', name='help',