HttpResponseExtensionMethods
A static class in Alta.Api.DataTransferModels, Alta.Api.DataTransferModels.Extensions.
Turns API responses into results or exceptions, and logs them.
- Listed in Alta.Api.DataTransferModels
- Attributes
Extension
Fields
2 private and internal fields
Methods
| Member | What it is |
|---|---|
static async Task<Exception> HandleForbiddenOrOtherHttpStatus(HttpResponseMessage response) | Logs a failed response and returns a ForbiddenException for 403 or an HttpException for anything else. |
static async Task<T> HandleResponse<T>(HttpResponseMessage response) | Returns the body as T on success, otherwise throws an ApiErrorException (400) or the exception from HandleForbiddenOrOtherHttpStatus. |
static async Task LogDebugResponse(HttpResponseMessage response) | Writes the method, URI, headers, body and request id to the debug log. |
static async Task LogErrorResponse(HttpResponseMessage response) | Writes the method, URI, headers, body and request id to the error log. |
1 private and internal method
| Member | What it is |
|---|---|
private static async Task<ApiErrorException> CreateApiErrorExceptionAsync(HttpResponseMessage response) | Reads a 400 body as an ApiError and wraps it in an ApiErrorException; unreadable bodies become an UnspecifiedError. |