[ease/plugins: 24/37] Handle error slightly more gracefully.



commit c9dca24587cbb55f057cb350ecf81aa1e9c49d32
Author: Stéphane Maniaci <stephane maniaci gmail com>
Date:   Mon Jun 21 05:37:28 2010 +0200

    Handle error slightly more gracefully.

 plugins/flickr.vala |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/plugins/flickr.vala b/plugins/flickr.vala
index f359f6d..e77864f 100644
--- a/plugins/flickr.vala
+++ b/plugins/flickr.vala
@@ -101,8 +101,17 @@ public class FlickrFetcher {
 			error ("Couldn't parse JSON data: %s", e.message);
 		}
 
-		print ("Payload: %s\nDELIMIT", jsondata);
+		print ("==START PAYLOAD==\n%s\n==END PAYLOAD==", jsondata);
 		Json.Object obj = parser.get_root().get_object ();
+
+		var stat = obj.get_string_member ("stat");
+		if (stat != "ok") {
+			print ("The request failed : \nError code: %G\nMessage: %s",
+				   obj.get_int_member ("code"),
+				   obj.get_string_member ("message"));
+			return;
+		}
+
 		var photos = obj.get_object_member ("photos");
 		var photo_array = photos.get_array_member ("photo");
 
@@ -118,9 +127,9 @@ public class FlickrFetcher {
 				string server = photo.get_string_member ("server");
 				string id = photo.get_string_member ("id");
 				string http = "http://farm";;
-				string stat = ".static.flickr.com/";
+				string flickr = ".static.flickr.com/";
 
-				string uri = http + farm + stat + server + "/" + id + "_" + secret + "_t.jpg";
+				string uri = http + farm + flickr + server + "/" + id + "_" + secret + "_t.jpg";
 				// TODO : unittest to track Flickr's URIs changes.
 
 				var pixbuf = gdk_pixbug_from_uri (uri);



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