Skip to content

Commit

Permalink
Catch PDF is damaged error
Browse files Browse the repository at this point in the history
  • Loading branch information
dreua committed Apr 19, 2020
1 parent 5822aa4 commit 9c3b652
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pdfarranger/pdfarranger.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,13 +756,7 @@ def on_action_add_doc_activate(self, _action, _param, _unknown):
if response == Gtk.ResponseType.ACCEPT:
adder = PageAdder(self)
for filename in chooser.get_filenames():
try:
adder.addpages(filename)
except Exception as e:
traceback.print_exc()
chooser.destroy()
self.error_message_dialog(e)
return
adder.addpages(filename)
adder.commit(select_added=False, add_to_undomanager=True)
chooser.destroy()

Expand Down Expand Up @@ -1489,7 +1483,13 @@ def addpages(self, filename, page=-1, angle=0, crop=None):
break

if not pdfdoc:
pdfdoc = PDFDoc(filename, self.app.tmp_dir)
try:
pdfdoc = PDFDoc(filename, self.app.tmp_dir)
except GLib.Error as e:
message = e.message + ': ' + filename
print(message, file=sys.stderr)
self.app.error_message_dialog(message)
return
self.app.import_directory = os.path.split(filename)[0]
self.app.export_directory = self.app.import_directory
self.app.pdfqueue.append(pdfdoc)
Expand Down

0 comments on commit 9c3b652

Please sign in to comment.