]> git.phdru.name Git - m_librarian.git/commitdiff
Feat(wx/books): Catch and report errors on downloading
authorOleg Broytman <phd@phdru.name>
Wed, 10 Jan 2024 01:04:33 +0000 (04:04 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 10 Jan 2024 01:04:33 +0000 (04:04 +0300)
[skip ci]

m_librarian/wx/ListBooks.py

index fb15d1fe671844c57b8bb81d25c13da00ef4c75c..4252c2a45df0697750faf1183b94852e9ddd4415 100644 (file)
@@ -183,10 +183,23 @@ class ListBooksPanel(GridPanel):
 
     def Download(self, event):
         book_by_row = self.book_by_row
-        for row in self.toggle_rows[0]:
-            value = self.grid.GetCellValue(row, 0)
-            if value and row in book_by_row:
-                download(book_by_row[row])
+        found_books = False
+        try:
+            for row in self.toggle_rows[0]:
+                value = self.grid.GetCellValue(row, 0)
+                if value and row in book_by_row:
+                    found_books = True
+                    download(book_by_row[row])
+        except Exception as e:
+            self.report_error(str(e))
+        else:
+            if not found_books:
+                self.report_error(u'Не выбрано книг для сохранения.')
+
+    def report_error(self, error):
+        wx.MessageBox(
+            error, caption='m_Librarian download error',
+            style=wx.OK|wx.ICON_ERROR, parent=self.Parent)
 
 
 class ListBooksWindow(GridWindow):