Add Exceptionhandler, AlertService JSON-Converter AppSettings via DI Reformat Code
23 lines
685 B
C#
23 lines
685 B
C#
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) {
|
|
}
|
|
} |