From dfc3e56eb79965117c4ebfb489d9e71779878b39 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Wed, 5 Jan 2022 13:16:07 +0100 Subject: [PATCH 1/3] Check if we're in debug and set IncludeErrorPolicy accordingly --- src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs b/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs index a62df6b5e4..3df6ffb47b 100644 --- a/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs +++ b/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs @@ -1,4 +1,5 @@ -using System.Web.Http; +using System.Web; +using System.Web.Http; using System.Web.Http.Controllers; using System.Web.Http.Filters; @@ -11,7 +12,7 @@ namespace Umbraco.Web.WebApi { public override void OnActionExecuting(HttpActionContext actionContext) { - actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; + actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = HttpContext.Current.IsDebuggingEnabled ? IncludeErrorDetailPolicy.Always : IncludeErrorDetailPolicy.Default; } } } From 0e9525d216ea66ea4eaf2528ca25717e5e7b9cc1 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Mon, 17 Jan 2022 08:32:13 +0100 Subject: [PATCH 2/3] Added null check --- src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs b/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs index 3df6ffb47b..5d6d53ab52 100644 --- a/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs +++ b/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs @@ -12,7 +12,12 @@ namespace Umbraco.Web.WebApi { public override void OnActionExecuting(HttpActionContext actionContext) { - actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = HttpContext.Current.IsDebuggingEnabled ? IncludeErrorDetailPolicy.Always : IncludeErrorDetailPolicy.Default; + if (HttpContext.Current?.IsDebuggingEnabled ?? false) + { + actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; + } + + actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Default; } } } From 72f30eb937c63433c83eefb35e534eacb0f77df4 Mon Sep 17 00:00:00 2001 From: Elitsa Marinovska Date: Tue, 18 Jan 2022 15:19:05 +0100 Subject: [PATCH 3/3] Adding else case --- src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs b/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs index 5d6d53ab52..ef07dfcb79 100644 --- a/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs +++ b/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs @@ -16,8 +16,10 @@ namespace Umbraco.Web.WebApi { actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; } - - actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Default; + else + { + actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Default; + } } } }