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



commit 4ea9b5cacf0b3ff858eb1d4b1830326fa07d571e
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 4599bbf..4329b95 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]