GetRestException() static private method

Gets the rest exception if possible.
static private GetRestException ( object result ) : FacebookApiException
result object The web request result object to check for exception information.
return FacebookApiException
        /// <summary>
        /// Processes the batch result.
        /// </summary>
        /// <param name="result">
        /// The json result.
        /// </param>
        /// <returns>
        /// Batch result.
        /// </returns>
        internal static object ProcessBatchResult(object result)
        {
            Contract.Requires(result != null);
            Contract.Ensures(Contract.Result <object>() != null);

            IList <object> list = new JsonArray();

            var resultList = (IList <object>)result;

            foreach (var row in resultList)
            {
                var body      = (string)((IDictionary <string, object>)row)["body"];
                var exception = ExceptionFactory.GetGraphException(body);

                object jsonObject = null;
                if (exception == null)
                {
                    // check for rest exception
                    jsonObject = JsonSerializer.Current.DeserializeObject(body);
                    exception  = ExceptionFactory.GetRestException(jsonObject);
                }

                list.Add(exception ?? jsonObject);
            }

            return(list);
        }