From f849c5fcc975c5955012b85b34826a51a09653b0 Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Mon, 4 Mar 2024 21:52:13 -0500
Subject: [PATCH] compiler: Don't show ExceptionContext of GhcExceptions

Most GhcExceptions are user-facing errors and therefore the
ExceptionContext has little value. Ideally we would enable
it in the DEBUG compiler but I am leaving this for future work.
---
 compiler/GHC/Utils/Panic.hs | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/compiler/GHC/Utils/Panic.hs b/compiler/GHC/Utils/Panic.hs
index fb94c9f79f2e..d93de5c55181 100644
--- a/compiler/GHC/Utils/Panic.hs
+++ b/compiler/GHC/Utils/Panic.hs
@@ -127,6 +127,10 @@ instance Exception GhcException where
           PlainProgramError str -> ProgramError str
     | otherwise = Nothing
 
+  -- Explicitly omit ExceptionContext since we generally don't
+  -- want backtraces and other context in GHC's user errors.
+  displayException exc = showGhcExceptionUnsafe exc ""
+
 instance Show GhcException where
   showsPrec _ e = showGhcExceptionUnsafe e
 
-- 
GitLab