catch attempts to nest under a filtered deck; don't show traceback

This commit is contained in:
Damien Elmes 2021-03-01 09:58:12 +10:00
parent 5564fd9e13
commit 32af54cd4d
4 changed files with 14 additions and 3 deletions

View File

@ -1,4 +1,4 @@
errors-invalid-input-empty = Invalid input.
errors-invalid-input-details = Invalid input: { $details }
errors-parse-number-fail = A number was invalid or out of range.
errors-filtered-parent-deck = Invalid deck name: Filtered decks cannot be parent decks.
errors-filtered-parent-deck = Filtered decks can not have child decks.

View File

@ -287,7 +287,11 @@ class DeckBrowser:
self._renderPage(reuse=True)
def _handle_drag_and_drop(self, source: int, target: int) -> None:
self.mw.col.decks.drag_drop_decks([source], target)
try:
self.mw.col.decks.drag_drop_decks([source], target)
except Exception as e:
showWarning(str(e))
return
gui_hooks.sidebar_should_refresh_decks()
self.show()

View File

@ -472,7 +472,11 @@ class SidebarTreeView(QTreeView):
def on_done(fut: Future) -> None:
self.browser.model.endReset()
fut.result()
try:
fut.result()
except Exception as e:
showWarning(str(e))
return
self.refresh()
self.mw.deckBrowser.refresh()

View File

@ -605,6 +605,9 @@ impl Collection {
let mut target_name = None;
if let Some(target) = target {
if let Some(target) = col.storage.get_deck(target)? {
if target.is_filtered() {
return Err(AnkiError::DeckIsFiltered);
}
target_deck = target;
target_name = Some(target_deck.name.as_str());
}