summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-09-17 13:06:36 +0100
committerSimon Marlow <marlowsd@gmail.com>2011-09-21 09:53:10 +0100
commit222589a9f270d90f4ac21bf22b0a82e8ae126718 (patch)
tree6dbc2de4a32cc0d014ad9f006d61aa215c82766e
parent3db757241ce7fb99c096c30481aefa86bb9855a1 (diff)
downloadhaskell-222589a9f270d90f4ac21bf22b0a82e8ae126718.tar.gz
fix bug in :show bindings when a variable is bound to an exception
-rw-r--r--compiler/ghci/Debugger.hs10
1 files changed, 8 insertions, 2 deletions
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