Skip to content

Commit 46bcee6

Browse files
committed
Add DebugView SomeException
1 parent 29c18be commit 46bcee6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • haskell-debugger-view/src/GHC/Debugger/View

haskell-debugger-view/src/GHC/Debugger/View/Class.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module GHC.Debugger.View.Class
5151

5252
import Data.Int
5353
import Data.Word
54+
import Control.Exception
5455

5556
-- | Custom handling of debug terms (e.g. in the variables pane, or when
5657
-- inspecting a lazy variable)
@@ -180,6 +181,15 @@ instance DebugView (a, b) where
180181
[ ("fst", VarFieldValue x)
181182
, ("snd", VarFieldValue y) ]
182183

184+
instance DebugView SomeException where
185+
debugValue e = simpleValue (displayException e) True
186+
debugFields e@(SomeException exc) =
187+
let !ctx = someExceptionContext e
188+
in pure $ VarFields
189+
[ ("exception", VarFieldValue exc)
190+
, ("context", VarFieldValue ctx)
191+
]
192+
183193
-- | This instance will display up to the first 50 forced elements of a list.
184194
instance {-# OVERLAPPABLE #-} DebugView [a] where
185195
debugValue [] = simpleValue "[]" False
@@ -219,4 +229,3 @@ toVarFieldsIO :: VarFields -> [(IO String, VarFieldValue)]
219229
toVarFieldsIO x =
220230
case x of
221231
VarFields fls -> [ (pure fl_s, b) | (fl_s, b) <- fls]
222-

0 commit comments

Comments
 (0)