Exemplo n.º 1
0
        /// <summary>
        /// Validates the specified <paramref name="response"/>.
        /// </summary>
        /// <param name="response">The response to be validated.</param>
        public static void ValidateResponse(SocialHttpResponse response)
        {
            // Skip error checking if the server responds with an OK status code
            if (response.StatusCode == HttpStatusCode.OK)
            {
                return;
            }
            if (response.StatusCode == HttpStatusCode.Created)
            {
                return;
            }

            // Parse the JSON response
            PinterestError error = ParseJsonObject(response.Body, PinterestError.Parse);

            // Throw the exception
            throw new PinterestHttpException(response, error);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new exception based on the specified <paramref name="response"/> and Pinterest <paramref name="error"/>.
 /// </summary>
 /// <param name="response">The response received from the Pinterest API.</param>
 /// <param name="error">The error message.</param>
 public PinterestHttpException(SocialHttpResponse response, PinterestError error) : base("The Pinterest API responded with an error (" + error.Message + ")")
 {
     Response = response;
     Error    = error;
 }