Added verb to error messages, so we have "POST http://... failed" instead of "Request to http://... failed"
This commit is contained in:
parent
1fe170b274
commit
47f63677df
@ -38,18 +38,14 @@ namespace Flurl.Http
|
||||
public FlurlHttpException(HttpCall call) : this(call, BuildMessage(call, null), null) { }
|
||||
|
||||
private static string BuildMessage(HttpCall call, Exception inner) {
|
||||
if (call.Response != null && !call.Succeeded) {
|
||||
return string.Format("Request to {0} failed with status code {1} ({2}).",
|
||||
call.Request.RequestUri.AbsoluteUri,
|
||||
(int)call.Response.StatusCode,
|
||||
call.Response.ReasonPhrase);
|
||||
}
|
||||
if (inner != null) {
|
||||
return $"Request to {call.Request.RequestUri.AbsoluteUri} failed. {inner.Message}";
|
||||
}
|
||||
if (call.Response != null && !call.Succeeded)
|
||||
return $"{call} failed with status code {(int)call.Response.StatusCode} ({call.Response.ReasonPhrase}).";
|
||||
|
||||
if (inner != null)
|
||||
return $"{call} failed. {inner.Message}";
|
||||
|
||||
// in theory we should never get here.
|
||||
return $"Request to {call.Request.RequestUri.AbsoluteUri} failed.";
|
||||
return $"{call} failed.";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -93,7 +89,7 @@ namespace Flurl.Http
|
||||
public FlurlHttpTimeoutException(HttpCall call, Exception inner) : base(call, BuildMessage(call), inner) { }
|
||||
|
||||
private static string BuildMessage(HttpCall call) {
|
||||
return $"Request to {call} timed out.";
|
||||
return $"{call} timed out.";
|
||||
}
|
||||
}
|
||||
}
|
@ -108,5 +108,13 @@ namespace Flurl.Http
|
||||
/// Body of the HTTP response if unsuccessful, otherwise null. (Successful responses are not captured as strings, mainly for performance reasons.)
|
||||
/// </summary>
|
||||
public string ErrorResponseBody { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the verb and absolute URI associated with this call.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString() {
|
||||
return $"{Request.Method:U} {Request.RequestUri.AbsoluteUri}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user