/// <summary> /// Initializes a new instance of the <see cref="HttpAgentResult{T}"/> class using an existing <see cref="WebApiAgentResult"/>. /// </summary> /// <param name="result">The result containing the <see cref="WebApiAgentResult.Content"/> to deserialize.</param> /// <param name="overrideValue">The value overriding the internal content deserialization.</param> public HttpAgentResult(HttpAgentResult result, T overrideValue = default !) : this(Check.NotNull(result, nameof(result)).SendArgs, result.Response, overrideValue) { Content = result.Content; Messages = result.Messages; ErrorType = result.ErrorType; ErrorMessage = result.ErrorMessage; }
/// <summary> /// Throws an exception if the <see cref="WebApiAgentResult.Response"/> <see cref="HttpResponseMessage.IsSuccessStatusCode"/> for the HTTP response is false /// (see <see cref="HttpResponseMessage.EnsureSuccessStatusCode"/>). /// </summary> /// <returns>The <see cref="HttpAgentResult{T}"/> instance to support fluent/chaining usage.</returns> public new HttpAgentResult <T> ThrowOnError() { if (StatusCode == HttpStatusCode.NotFound && SendArgs.NullOnNotFoundResponse) { return(this); } HttpAgentResult.ThrowBeefExceptionOnError(this); base.ThrowOnError(); return(this); }