[banshee] Lastfm: refactor to place the error handling at the end



commit d16f8ef6b27d76f43783091defce3d6990327dba
Author: Andres G. Aragoneses <knocte gmail com>
Date:   Sat Mar 16 20:48:16 2013 +0000

    Lastfm: refactor to place the error handling at the end
    
    It's a bit more readable if the code for error handling is the last code
    in the method. It's still a bit ugly though because it uses error handling
    instead of exception handling.

 .../Lastfm/Lastfm/AudioscrobblerConnection.cs      |   28 ++++++++++----------
 1 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs 
b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
index 3a10e04..03a192c 100644
--- a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
+++ b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
@@ -287,20 +287,7 @@ namespace Lastfm
                 return;
             }
 
-            if (error != StationError.None) {
-                // TODO: If error == StationError.InvalidSessionKey,
-                // suggest to the user to (re)do the Last.fm authentication.
-                hard_failures++;
-
-                queue.RemoveInvalidTracks ();
-
-                // if there are still valid tracks in the queue then retransmit on the next interval
-                if (queue.Count > 0) {
-                    state = State.NeedTransmit;
-                } else {
-                    state = State.Idle;
-                }
-            } else {
+            if (error == StationError.None) {
                 try {
                     var scrobbles = (JsonObject)response["scrobbles"];
                     var scrobbles_attr = (JsonObject)scrobbles["@attr"];
@@ -328,6 +315,19 @@ namespace Lastfm
                 queue.Save ();
 
                 state = State.Idle;
+            } else {
+                // TODO: If error == StationError.InvalidSessionKey,
+                // suggest to the user to (re)do the Last.fm authentication.
+                hard_failures++;
+
+                queue.RemoveInvalidTracks ();
+
+                // if there are still valid tracks in the queue then retransmit on the next interval
+                if (queue.Count > 0) {
+                    state = State.NeedTransmit;
+                } else {
+                    state = State.Idle;
+                }
             }
         }
 


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