From f6d2fd329d1dc5890ff68dec2e0b5509373368a2 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 29 Sep 2024 00:29:53 +0200 Subject: [PATCH] [backend/middleware] Fix error responses always returning 500 --- Iceshrimp.Shared/Schemas/Web/ErrorResponse.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Iceshrimp.Shared/Schemas/Web/ErrorResponse.cs b/Iceshrimp.Shared/Schemas/Web/ErrorResponse.cs index 5e6248bf..e33da647 100644 --- a/Iceshrimp.Shared/Schemas/Web/ErrorResponse.cs +++ b/Iceshrimp.Shared/Schemas/Web/ErrorResponse.cs @@ -5,8 +5,13 @@ using JI = System.Text.Json.Serialization.JsonIgnoreAttribute; namespace Iceshrimp.Shared.Schemas.Web; [XmlRoot("Error")] -public class ErrorResponse(Exception exception) +public class ErrorResponse() { + public ErrorResponse(Exception exception) : this() + { + Exception = exception; + } + [XmlElement("Status")] public required int StatusCode { get; set; } [XmlElement("Error")] public required string Error { get; set; } @@ -38,7 +43,7 @@ public class ErrorResponse(Exception exception) [XmlElement("RequestId")] public required string RequestId { get; set; } - [JI] [XmlIgnore] public Exception Exception => exception; + [JI] [XmlIgnore] public Exception Exception = new(); } public class XmlValidationError