add UserRendererService and improve errors

This commit is contained in:
sam 2024-05-28 17:09:50 +02:00
parent 6114f384a0
commit f674d059fd
14 changed files with 607 additions and 25 deletions

View file

@ -45,7 +45,7 @@ public class ErrorHandlerMiddleware(ILogger baseLogger) : IMiddleware
await ctx.Response.WriteAsync(JsonConvert.SerializeObject(new HttpApiError
{
Status = (int)ae.StatusCode,
Code = ErrorCode.GenericApiError,
Code = ae.ErrorCode,
Message = ae.Message,
}));
return;
@ -76,18 +76,12 @@ public class ErrorHandlerMiddleware(ILogger baseLogger) : IMiddleware
public record HttpApiError
{
public required int Status { get; init; }
[JsonConverter(typeof(StringEnumConverter))]
public required ErrorCode Code { get; init; }
public required string Message { get; init; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string[]? Scopes { get; init; }
}
public enum ErrorCode
{
InternalServerError,
Forbidden,
BadRequest,
AuthenticationError,
GenericApiError,
}