[f-spot: 1/4] More properly handle XML document errors



commit 86eee210ffc4942035e5b816b756fcd77e63f5ed
Author: Jim Ramsay <i am jimramsay com>
Date:   Tue Jun 16 19:30:25 2009 -0400

    More properly handle XML document errors
    
    Not every exception thrown will be parsed properly as an actual facebook error,
    so the second parse in the catch block may also throw an exception.  Catch it
    too and display the original exception on stderr for easier debugging.

 .../Exporters/FacebookExport/Mono.Facebook/Util.cs |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/extensions/Exporters/FacebookExport/Mono.Facebook/Util.cs b/extensions/Exporters/FacebookExport/Mono.Facebook/Util.cs
index 79c5fbf..43dc7a3 100644
--- a/extensions/Exporters/FacebookExport/Mono.Facebook/Util.cs
+++ b/extensions/Exporters/FacebookExport/Mono.Facebook/Util.cs
@@ -89,8 +89,15 @@ namespace Mono.Facebook
 				T response = (T)response_serializer.Deserialize(new MemoryStream(response_bytes));
 				return response;
 			}
-			catch {
-				Error error = (Error) ErrorSerializer.Deserialize (new MemoryStream (response_bytes));
+			catch (Exception outer) {
+				Error error;
+				try {
+					error = (Error) ErrorSerializer.Deserialize (new MemoryStream (response_bytes));
+				}
+				catch {
+					Console.Error.Write (outer.ToString());
+					throw new FacebookException (-1, "Internal error: Could not parse facebook response");
+				}
 				throw new FacebookException (error.ErrorCode, error.ErrorMsg);
 			}
 		}



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