From: Oleg Broytman Date: Wed, 10 Jan 2024 01:04:33 +0000 (+0300) Subject: Feat(wx/books): Catch and report errors on downloading X-Git-Tag: 0.3.0~9^2 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=7c53383385f4f6d40ddf5ecc3aad280a5cdb63cf;p=m_librarian.git Feat(wx/books): Catch and report errors on downloading [skip ci] --- diff --git a/m_librarian/wx/ListBooks.py b/m_librarian/wx/ListBooks.py index fb15d1f..4252c2a 100644 --- a/m_librarian/wx/ListBooks.py +++ b/m_librarian/wx/ListBooks.py @@ -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):