Swiss Army Knife
General utility tools for Scada Minds
|
Methods for working with more efficiently with HttpResponses. More...
Static Public Member Functions | |
static async Task | EnsureSuccessStatusCodeOrLogAsync (this HttpResponseMessage message, Action< HttpRequestException, string > beforeThrowing) |
Ensures that the HttpResponse returns with an OK status code. If it does not, it will call the "beforeThrowing" function, and then throw a HttpRequestException. It will pass the error and the request body as a string into the orElseFunction. More... | |
Methods for working with more efficiently with HttpResponses.
|
inlinestatic |
Ensures that the HttpResponse returns with an OK status code. If it does not, it will call the "beforeThrowing" function, and then throw a HttpRequestException. It will pass the error and the request body as a string into the orElseFunction.
It basically works like EnsureStatusCode, except that it gives you a logging hook.
message | The HttpResponseMessage to ensure is valid. |
beforeThrowing | The function to be called if the request was not successful. This will get passed the HttpRequestException, and the response body. You do not need to throw the error. |