/
IErrorHandler.cs
18 lines (17 loc) · 1.04 KB
/
IErrorHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
namespace TypedRest.Errors;
/// <summary>
/// Handles errors in HTTP responses.
/// </summary>
public interface IErrorHandler
{
/// <summary>
/// Throws appropriate <see cref="Exception"/>s based on HTTP status codes and response bodies.
/// </summary>
/// <exception cref="InvalidDataException"><see cref="HttpStatusCode.BadRequest"/></exception>
/// <exception cref="AuthenticationException"><see cref="HttpStatusCode.Unauthorized"/></exception>
/// <exception cref="UnauthorizedAccessException"><see cref="HttpStatusCode.Forbidden"/></exception>
/// <exception cref="KeyNotFoundException"><see cref="HttpStatusCode.NotFound"/> or <see cref="HttpStatusCode.Gone"/></exception>
/// <exception cref="InvalidOperationException"><see cref="HttpStatusCode.Conflict"/>, <see cref="HttpStatusCode.PreconditionFailed"/> or <see cref="HttpStatusCode.RequestedRangeNotSatisfiable"/></exception>
/// <exception cref="HttpRequestException">Other non-success status code.</exception>
Task HandleAsync(HttpResponseMessage response);
}