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