Facebook.ExceptionFactory.CheckForRestException C# (CSharp) Method

CheckForRestException() static private method

Checks for rest exception.
static private CheckForRestException ( Uri>.IDictionary domainMaps, Uri requestUri, object json ) : FacebookApiException
domainMaps Uri>.IDictionary /// The domain maps. ///
requestUri System.Uri /// The request uri. ///
json object /// The json string. ///
return FacebookApiException
        internal static FacebookApiException CheckForRestException(IDictionary<string, Uri> domainMaps, Uri requestUri, object 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
                error = GetRestException(json);
            }

            return error;
        }

Same methods

ExceptionFactory::CheckForRestException ( Uri>.IDictionary domainMaps, Uri requestUri, string json ) : FacebookApiException

Usage Example

        internal protected virtual object Api(string path, IDictionary <string, object> parameters, HttpMethod httpMethod, Type resultType)
        {
            var mergedParameters = FacebookUtils.Merge(null, parameters);

            if (!mergedParameters.ContainsKey("access_token") && !string.IsNullOrEmpty(AccessToken))
            {
                mergedParameters["access_token"] = AccessToken;
            }

            Uri    requestUrl;
            string contentType;

            byte[] postData = BuildRequestData(path, mergedParameters, httpMethod, out requestUrl, out contentType);

            var jsonString = MakeRequest(httpMethod, requestUrl, postData, contentType);

            var json = JsonSerializer.Current.DeserializeObject(jsonString);

            FacebookApiException facebookApiException =
                ExceptionFactory.GetGraphException(json) ??
                ExceptionFactory.CheckForRestException(DomainMaps, requestUrl, json);

            if (facebookApiException != null)
            {
                throw facebookApiException;
            }

            return(resultType == null ? json : JsonSerializer.Current.DeserializeObject(jsonString, resultType));
        }
All Usage Examples Of Facebook.ExceptionFactory::CheckForRestException