Ejemplo n.º 1
0
        /// <summary>
        /// Converts to exceptions.
        /// </summary>
        /// <param name="restResponse">The rest response.</param>
        /// <param name="response">The response.</param>
        /// <exception cref="Trident.Rest.RestException">
        /// Error calling REST API.  {restResponse.ErrorMessage}
        /// or
        /// Error calling REST API. {restResponse.Content}
        /// </exception>
        /// <summary>
        /// Converts to exceptions.
        /// </summary>
        /// <param name="restResponse">The rest response.</param>
        /// <param name="response">The response.</param>
        /// <exception cref="RestException">
        /// Error calling REST API.  {restResponse.ErrorMessage}
        /// or
        /// Error calling REST API. {restResponse.Content}
        /// </exception>
        private static void NormalizeErrorsToExceptions(IRestResponse restResponse, RestResponse response)
        {
            if (restResponse.ErrorException != null)
            {
                throw new RestException(response, $"Error calling REST API.  {restResponse.ErrorMessage}.  Check inner exception for details.", restResponse.ErrorException);
            }

            if ((int)restResponse.StatusCode >= 300 || (int)restResponse.StatusCode < 200)
            {
                throw new RestException(response, $"Error calling REST API. {restResponse.Content}");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RestException"/> class.
 /// </summary>
 /// <param name="response">The response.</param>
 /// <param name="message">The message.</param>
 /// <param name="innerException">The inner exception.</param>
 public RestException(RestResponse response, string message, Exception innerException) : base(message, innerException)
 {
     Response = response;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RestException"/> class.
 /// </summary>
 /// <param name="response">The response.</param>
 /// <param name="message">The message.</param>
 public RestException(RestResponse response, string message) : base(message)
 {
     Response = response;
 }