[gnome-music/wip/mschraal/grltrackerplaylist-empty-playlist-delete: 8/9] grltrackerplaylists: Catch deletion failure



commit 11a660af3afca0000e2f98590a324881b918e58f
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Feb 9 16:28:18 2020 +0100

    grltrackerplaylists: Catch deletion failure
    
    Add a try/except for the async playlist deletion finish.
    
    Related: #365

 gnomemusic/grilowrappers/grltrackerplaylists.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index e9b73458..f63da4af 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -185,12 +185,16 @@ class GrlTrackerPlaylists(GObject.GObject):
             return
 
         def _delete_cb(conn, res, data):
-            # FIXME: Check for failure.
-            conn.update_finish(res)
-            for idx, playlist_model in enumerate(self._model):
-                if playlist_model is playlist:
-                    self._model.remove(idx)
-                    break
+            try:
+                conn.update_finish(res)
+            except GLib.Error as error:
+                self._log.warning("Unable to delete playlist {}: {}".format(
+                    playlist.props.title, error.message))
+            else:
+                for idx, playlist_model in enumerate(self._model):
+                    if playlist_model is playlist:
+                        self._model.remove(idx)
+                        break
 
             self._model_filter.set_filter_func(self._playlists_filter)
             self._window.notifications_popup.pop_loading()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]