This commit is contained in:
parent
edcf60a62c
commit
9979491571
@ -55,5 +55,11 @@ namespace Flurl.Test.Http
|
|||||||
Assert.IsInstanceOf<Newtonsoft.Json.JsonReaderException>(ex.InnerException);
|
Assert.IsInstanceOf<Newtonsoft.Json.JsonReaderException>(ex.InnerException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test] // #579
|
||||||
|
public void can_create_empty() {
|
||||||
|
var ex = new FlurlHttpException(null);
|
||||||
|
Assert.AreEqual("Call failed.", ex.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,13 @@ namespace Flurl.Http
|
|||||||
public FlurlHttpException(FlurlCall call) : this(call, BuildMessage(call, null), null) { }
|
public FlurlHttpException(FlurlCall call) : this(call, BuildMessage(call, null), null) { }
|
||||||
|
|
||||||
private static string BuildMessage(FlurlCall call, Exception inner) {
|
private static string BuildMessage(FlurlCall call, Exception inner) {
|
||||||
return
|
if (call?.Response != null && !call.Succeeded)
|
||||||
(call.Response != null && !call.Succeeded) ?
|
return $"Call failed with status code {call.Response.StatusCode} ({call.HttpResponseMessage.ReasonPhrase}): {call}";
|
||||||
$"Call failed with status code {call.Response.StatusCode} ({call.HttpResponseMessage.ReasonPhrase}): {call}":
|
|
||||||
$"Call failed. {inner?.Message} {call}";
|
var msg = "Call failed.";
|
||||||
|
if (inner != null) msg += " " + inner.Message;
|
||||||
|
if (call != null) msg += " " + call;
|
||||||
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user