示例#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;
     }
 }
示例#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}");
 }
示例#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}"));
        }
示例#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)
 {
 }
示例#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)
 {
 }
示例#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;
 }
示例#7
0
        private static string BuildMessage(FlurlCall call, string expectedFormat)
        {
            var msg = $"Response could not be deserialized to {expectedFormat}";

            return(msg + ((call == null) ? "." : $": {call}"));
        }
示例#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;
 }
示例#9
0
 private static string BuildMessage(FlurlCall call) =>
 (call == null) ? "Call timed out." :  $"Call timed out: {call}";
示例#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)
 {
 }
示例#11
0
 private static string BuildMessage(FlurlCall call)
 {
     return($"Call timed out: {call}");
 }
示例#12
0
 private static string BuildMessage(FlurlCall call, string expectedFormat)
 {
     return($"Response could not be deserialized to {expectedFormat}: {call}");
 }