[banshee/stable-2.6] LastFm: Avoid crashing if scrobbling response is not JSON (bgo#689016)



commit adffa2e49ebd211a2b974816ba24c7d7baa95452
Author: Phil Trimble <PhilTrimble gmail com>
Date:   Tue Jan 15 00:17:04 2013 +0000

    LastFm: Avoid crashing if scrobbling response is not JSON (bgo#689016)
    
    Improves exception handling for invalid responses from Last.fm. The
    specific reported in bgo#689016 is about a '414' error from Last.fm but
    this change would catch any exception thrown while processing the last.fm
    response.
    
    This only addresses the crash caused by not handling the exception,
    not the root cause.
    
    Signed-off-by: Andres G. Aragoneses <knocte gmail com>

 .../Lastfm/Lastfm/AudioscrobblerConnection.cs      |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs 
b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
index 7c5e871..5410308 100644
--- a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
+++ b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
@@ -248,7 +248,15 @@ namespace Lastfm
                 return;
             }
 
-            var response = current_scrobble_request.GetResponseObject ();
+            JsonObject response = null;
+            try {
+                response = current_scrobble_request.GetResponseObject ();
+            } catch (Exception e) {
+                Log.Exception ("Failed to process the scrobble response", e);
+                state = State.Idle;
+                return;
+            }
+
             var error = current_scrobble_request.GetError ();
             if (error == StationError.ServiceOffline || error == StationError.TemporarilyUnavailable) {
                 Log.WarningFormat ("Lastfm is temporarily unavailable: {0}", (string)response ["message"]);


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