From 7c627982fec538199a8d490a76daaf4a8b57accd Mon Sep 17 00:00:00 2001 From: Greg Edwards Date: Mon, 13 Dec 2021 03:20:58 -0500 Subject: [PATCH] Show stack trace in HTTP responses when DEBUG is set. --- GamestatsBase/GamestatsHandler.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/GamestatsBase/GamestatsHandler.cs b/GamestatsBase/GamestatsHandler.cs index 55e49b1..b131852 100644 --- a/GamestatsBase/GamestatsHandler.cs +++ b/GamestatsBase/GamestatsHandler.cs @@ -224,11 +224,7 @@ namespace GamestatsBase } catch (Exception ex) { -#if DEBUG ShowError(context, 500, ex.ToString()); -#else - ShowError(context, 500); -#endif return; } @@ -250,16 +246,19 @@ namespace GamestatsBase } } - // todo: keep the context on a field instead of passing it here - public void ShowError(HttpContext context, int responseCode) + public static void ShowError(HttpContext context, int responseCode) { ShowError(context, responseCode, GamestatsException.defaultMessage(responseCode)); } - public void ShowError(HttpContext context, int responseCode, string message) + public static void ShowError(HttpContext context, int responseCode, string message) { context.Response.StatusCode = responseCode; +#if DEBUG + context.Response.Write(message); +#else context.Response.Write(GamestatsException.defaultMessage(responseCode)); +#endif } public virtual bool IsReusable