Beispiel #1
0
 /// <summary>
 /// Associate a FlurlCall object with this request
 /// </summary>
 internal static void SetFlurlCall(this HttpRequestMessage request, FlurlCall call)
 {
     if (request?.Properties != null)
     {
         request.Properties["FlurlHttpCall"] = call;
     }
 }
Beispiel #2
0
 private static string BuildMessage(FlurlCall call, Exception inner)
 {
     return
         ((call.Response != null && !call.Succeeded) ?
          $"Call failed with status code {call.Response.StatusCode} ({call.HttpResponseMessage.ReasonPhrase}): {call}":
          $"Call failed. {inner?.Message} {call}");
 }
Beispiel #3
0
        private static string BuildMessage(FlurlCall call, Exception inner)
        {
            if (call?.Response != null && !call.Succeeded)
            {
                return($"Call failed with status code {call.Response.StatusCode} ({call.HttpResponseMessage.ReasonPhrase}): {call}");
            }

            var msg = "Call failed";

            if (inner != null)
            {
                msg += ". " + inner.Message.TrimEnd('.');
            }
            return(msg + ((call == null) ? "." : $": {call}"));
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FlurlHttpException"/> class.
 /// </summary>
 /// <param name="call">The call.</param>
 public FlurlHttpException(FlurlCall call) : this(call, BuildMessage(call, null), null)
 {
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FlurlHttpException"/> class.
 /// </summary>
 /// <param name="call">The call.</param>
 /// <param name="inner">The inner.</param>
 public FlurlHttpException(FlurlCall call, Exception inner) : this(call, BuildMessage(call, inner), inner)
 {
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FlurlHttpException"/> class.
 /// </summary>
 /// <param name="call">The call.</param>
 /// <param name="message">The message.</param>
 /// <param name="inner">The inner.</param>
 public FlurlHttpException(FlurlCall call, string message, Exception inner) : base(message, inner)
 {
     Call = call;
 }
Beispiel #7
0
        private static string BuildMessage(FlurlCall call, string expectedFormat)
        {
            var msg = $"Response could not be deserialized to {expectedFormat}";

            return(msg + ((call == null) ? "." : $": {call}"));
        }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FlurlParsingException"/> class.
 /// </summary>
 /// <param name="call">Details of the HTTP call that caused the exception.</param>
 /// <param name="expectedFormat">The format that could not be parsed to, i.e. JSON.</param>
 /// <param name="inner">The inner exception.</param>
 public FlurlParsingException(FlurlCall call, string expectedFormat, Exception inner) : base(call, BuildMessage(call, expectedFormat), inner)
 {
     ExpectedFormat = expectedFormat;
 }
Beispiel #9
0
 private static string BuildMessage(FlurlCall call) =>
 (call == null) ? "Call timed out." :  $"Call timed out: {call}";
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FlurlHttpTimeoutException"/> class.
 /// </summary>
 /// <param name="call">Details of the HTTP call that caused the exception.</param>
 /// <param name="inner">The inner exception.</param>
 public FlurlHttpTimeoutException(FlurlCall call, Exception inner) : base(call, BuildMessage(call), inner)
 {
 }
Beispiel #11
0
 private static string BuildMessage(FlurlCall call)
 {
     return($"Call timed out: {call}");
 }
Beispiel #12
0
 private static string BuildMessage(FlurlCall call, string expectedFormat)
 {
     return($"Response could not be deserialized to {expectedFormat}: {call}");
 }