Exemplo n.º 1
0
        public static FacebookApiException TryGetRestException(IDictionary <string, Uri> domainMaps, Uri requestUri, object json)
        {
            FacebookApiException error = null;

            // HACK: We have to do this because the REST Api doesn't return
            // the correct status codes when an error has occurred.
            if (FacebookUtils.IsUsingRestApi(domainMaps, requestUri))
            {
                // If we are using the REST API we need to check for an exception
                error = GetRestException(json);
            }

            return(error);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks for rest exception.
        /// </summary>
        /// <param name="domainMaps">
        /// The domain maps.
        /// </param>
        /// <param name="requestUri">
        /// The request uri.
        /// </param>
        /// <param name="json">
        /// The json string.
        /// </param>
        /// <returns>
        /// Returns <see cref="FacebookApiException"/> if it is a rest exception otherwise null.
        /// </returns>
        internal static FacebookApiException CheckForRestException(IDictionary <string, Uri> domainMaps, Uri requestUri, string json)
        {
            Contract.Requires(requestUri != null);

            FacebookApiException error = null;

            // HACK: We have to do this because the REST Api doesn't return
            // the correct status codes when an error has occurred.
            if (FacebookUtils.IsUsingRestApi(domainMaps, requestUri))
            {
                // If we are using the REST API we need to check for an exception
                var resultObject = JsonSerializer.Current.DeserializeObject(json);
                error = GetRestException(resultObject);
            }

            return(error);
        }