Skip to content

Commit

Permalink
Fix spesmilo#613. User selects binary file or file that contains more…
Browse files Browse the repository at this point in the history
… than addresses. This shows a dialog explaining the problem to the user, rather than crashing.
  • Loading branch information
rt121212121 committed Jun 6, 2018
1 parent c3f26e5 commit 3f825ae
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gui/qt/qrtextedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ def file_input(self):
fileName, __ = QFileDialog.getOpenFileName(self, 'select file')
if not fileName:
return
with open(fileName, "r", encoding='utf-8') as f:
data = f.read()
try:
with open(fileName, "r", encoding='utf-8') as f:
data = f.read()
except UnicodeDecodeError as reason:
self.show_critical(_("Electron Cash was unable to open your file") + "\n" + str(reason), title=_("Unable to read file"))
return
self.setText(data)

def qr_input(self):
Expand Down

0 comments on commit 3f825ae

Please sign in to comment.