Refactor Api-Client
Add Exceptionhandler, AlertService JSON-Converter AppSettings via DI Reformat Code
This commit is contained in:
23
Jugenddienst Stunden/Infrastructure/Exceptions.cs
Normal file
23
Jugenddienst Stunden/Infrastructure/Exceptions.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Net;
|
||||
|
||||
namespace Jugenddienst_Stunden.Infrastructure;
|
||||
|
||||
internal class ApiException : Exception {
|
||||
public HttpStatusCode StatusCode { get; }
|
||||
public string? ResponseBody { get; }
|
||||
|
||||
public ApiException(string message, HttpStatusCode statusCode = 0, string? responseBody = null,
|
||||
Exception? inner = null)
|
||||
: base(message, inner) {
|
||||
StatusCode = statusCode;
|
||||
ResponseBody = responseBody;
|
||||
}
|
||||
|
||||
public static ApiException From(HttpStatusCode statusCode, string message, string? responseBody = null)
|
||||
=> new ApiException(message, statusCode, responseBody);
|
||||
}
|
||||
|
||||
internal class ValidationException : Exception {
|
||||
public ValidationException(string message) : base(message) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user