add more helper methods

This commit is contained in:
2024-08-22 14:38:15 +02:00
parent 519c292a1f
commit ab268e6584
4 changed files with 13 additions and 3 deletions

View File

@@ -5,9 +5,11 @@ namespace Pilz.Net.Api;
public record class ApiResponse(
HttpStatusCode StatusCode)
{
public bool IsOk => StatusCode != HttpStatusCode.OK;
public void EnsureOk()
{
if (StatusCode != HttpStatusCode.OK)
if (!IsOk)
throw new Exception("Api return is not ok!");
}
}