From: sof Date: Wed, 5 Dec 2001 00:06:32 +0000 (+0000) Subject: [project @ 2001-12-05 00:06:32 by sof] X-Git-Tag: Approximately_9120_patches~468 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=6e5735b5dfe4ce212d7bbea56ac11dcf7d65c8a9;p=ghc-hetmet.git [project @ 2001-12-05 00:06:32 by sof] reuse Panic.showGhcException --- diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 3705b53..4f08243 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,6 +1,6 @@ {-# OPTIONS -#include "Linker.h" -#include "SchedAPI.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.101 2001/10/31 12:51:08 simonmar Exp $ +-- $Id: InteractiveUI.hs,v 1.102 2001/12/05 00:06:32 sof Exp $ -- -- GHC Interactive User Interface -- @@ -320,17 +320,12 @@ runCommand c = showException (DynException dyn) = case fromDynamic dyn of - Nothing -> - io (putStrLn ("*** Exception: (unknown)")) - Just (PhaseFailed phase code) -> - io (putStrLn ("Phase " ++ phase ++ " failed (code " - ++ show code ++ ")")) - Just Interrupted -> - io (putStrLn "Interrupted.") - Just (CmdLineError s) -> - io (putStrLn s) -- omit the location for CmdLineError - Just other_ghc_ex -> - io (putStrLn (show other_ghc_ex)) + Nothing -> io (putStrLn ("*** Exception: (unknown)")) + Just Interrupted -> io (putStrLn "Interrupted.") + Just (CmdLineError s) -> io (putStrLn s) -- omit the location for CmdLineError + Just ph@PhaseFailed{} -> io (putStrLn (showGhcException ph)) -- ditto + Just other_ghc_ex -> io (print other_ghc_ex) + showException other_exception = io (putStrLn ("*** Exception: " ++ show other_exception)) diff --git a/ghc/compiler/utils/Panic.lhs b/ghc/compiler/utils/Panic.lhs index d273fe8..b6e1f0f 100644 --- a/ghc/compiler/utils/Panic.lhs +++ b/ghc/compiler/utils/Panic.lhs @@ -42,7 +42,8 @@ ghcError e = throwDyn e -- assumed to contain a location already, so we don't print one). data GhcException - = PhaseFailed String ExitCode -- an external phase (eg. cpp) failed + = PhaseFailed String -- name of phase + ExitCode -- an external phase (eg. cpp) failed | Interrupted -- someone pressed ^C | UsageError String -- prints the short usage msg after the error | CmdLineError String -- cmdline prob, but doesn't print usage @@ -63,7 +64,14 @@ instance Show GhcException where showGhcException (UsageError str) = showString str . showChar '\n' . showString short_usage showGhcException (PhaseFailed phase code) - = showString phase . showString " failed, code = " . shows code + = showString "phase `" . showString phase . + showString "' failed (exitcode = " . shows int_code . + showString ")" + where + int_code = + case code of + ExitSuccess -> (0::Int) + ExitFailure x -> x showGhcException (CmdLineError str) = showString str showGhcException (ProgramError str)