minimal improvements for ApiResponse
This commit is contained in:
@@ -12,9 +12,10 @@ public record class ApiResponse<T>(
|
||||
public bool IsOk => StatusCode == HttpStatusCode.OK && Message is not null;
|
||||
|
||||
[MemberNotNull(nameof(Message))]
|
||||
public void EnsureOk()
|
||||
public T EnsureOk()
|
||||
{
|
||||
if (!IsOk)
|
||||
throw new Exception("Api return is not ok!");
|
||||
throw new ApiException("Api return is not ok: " + StatusCode);
|
||||
return Message;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user