summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres G. Aragoneses <knocte@gmail.com>2013-03-16 20:48:16 +0000
committerAndres G. Aragoneses <knocte@gmail.com>2013-03-16 20:48:16 +0000
commitd16f8ef6b27d76f43783091defce3d6990327dba (patch)
treef6f90aa0b9064cd75ed60b0378b520b0d32d3ce6
parent95ab8b8a70af86d2c3ddce2de1ea9ed067b97a36 (diff)
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.
-rw-r--r--src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
index 3a10e043e..03a192c10 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;
+ }
}
}