From 222589a9f270d90f4ac21bf22b0a82e8ae126718 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Sat, 17 Sep 2011 13:06:36 +0100 Subject: fix bug in :show bindings when a variable is bound to an exception --- compiler/ghci/Debugger.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'compiler/ghci/Debugger.hs') diff --git a/compiler/ghci/Debugger.hs b/compiler/ghci/Debugger.hs index e859609527..c8946d6367 100644 --- a/compiler/ghci/Debugger.hs +++ b/compiler/ghci/Debugger.hs @@ -27,6 +27,7 @@ import GHC import Outputable import PprTyThing import MonadUtils +import Exception import Control.Monad import Data.List @@ -209,8 +210,13 @@ pprTypeAndContents id = do if pcontents then do let depthBound = 100 - term <- GHC.obtainTermFromId depthBound False id - docs_term <- showTerm term + -- If the value is an exception, make sure we catch it and + -- show the exception, rather than propagating the exception out. + e_term <- gtry $ GHC.obtainTermFromId depthBound False id + docs_term <- case e_term of + Right term -> showTerm term + Left exn -> return (text "*** Exception:" <+> + text (show (exn :: SomeException))) return $ pprdId <+> equals <+> docs_term else return pprdId -- cgit v1.2.1