diff options
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/Outputable.lhs | 4 | ||||
-rw-r--r-- | compiler/utils/Panic.lhs | 18 |
2 files changed, 15 insertions, 7 deletions
diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs index 25fa15e18d..5f4b1ff493 100644 --- a/compiler/utils/Outputable.lhs +++ b/compiler/utils/Outputable.lhs @@ -909,12 +909,12 @@ pprPanic = panicDoc pprSorry :: String -> SDoc -> a -- ^ Throw an exception saying "this isn't finished yet" -pprSorry = pprDebugAndThen sorry +pprSorry = sorryDoc pprPgmError :: String -> SDoc -> a -- ^ Throw an exception saying "bug in pgm being compiled" (used for unusual program errors) -pprPgmError = pprDebugAndThen pgmError +pprPgmError = pgmErrorDoc pprTrace :: String -> SDoc -> a -> a diff --git a/compiler/utils/Panic.lhs b/compiler/utils/Panic.lhs index 019eec387e..71233fb0a7 100644 --- a/compiler/utils/Panic.lhs +++ b/compiler/utils/Panic.lhs @@ -14,7 +14,7 @@ module Panic ( pgmError, panic, sorry, panicFastInt, assertPanic, trace, - panicDoc, + panicDoc, sorryDoc, pgmErrorDoc, Exception.Exception(..), showException, safeShowException, try, tryMost, throwTo, @@ -87,12 +87,14 @@ data GhcException -- | The user tickled something that's known not to work yet, -- but we're not counting it as a bug. | Sorry String + | PprSorry String SDoc -- | An installation problem. | InstallationError String -- | An error in the user's code, probably. - | ProgramError String + | ProgramError String + | PprProgramError String SDoc deriving (Typeable) instance Exception GhcException @@ -144,6 +146,8 @@ showGhcException exception showString ")" CmdLineError str -> showString str + PprProgramError str _ -> + showGhcException (ProgramError (str ++ "\n<<details unavailable>>")) ProgramError str -> showString str InstallationError str -> showString str Signal n -> showString "signal: " . shows n @@ -157,6 +161,8 @@ showGhcException exception ++ s ++ "\n\n" ++ "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\n" + PprSorry s _ -> + showGhcException (Sorry (s ++ "\n<<details unavailable>>")) Sorry s -> showString $ "sorry! (unimplemented feature or known bug)\n" @@ -192,12 +198,14 @@ panic x = unsafeDupablePerformIO $ do panic x = throwGhcException (Panic x) #endif -panicDoc :: String -> SDoc -> a -panicDoc x doc = throwGhcException (PprPanic x doc) - sorry x = throwGhcException (Sorry x) pgmError x = throwGhcException (ProgramError x) +panicDoc, sorryDoc, pgmErrorDoc :: String -> SDoc -> a +panicDoc x doc = throwGhcException (PprPanic x doc) +sorryDoc x doc = throwGhcException (PprSorry x doc) +pgmErrorDoc x doc = throwGhcException (PprProgramError x doc) + -- | Panic while pretending to return an unboxed int. -- You can't use the regular panic functions in expressions |