Commit d714c9b9 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov Committed by GitHub
Browse files

Merge pull request #4488 from ezyang/pr/improve-error-display

Improve error display in top level handler.
parents 26e77e16 c1de9a76
......@@ -369,6 +369,8 @@ annotateIO verbosity = modifyIOError f
. withMetadata NeverMark VerboseTrace verbosity
$ ioeGetErrorString ioe
{-# NOINLINE topHandlerWith #-}
topHandlerWith :: forall a. (Exception.SomeException -> IO a) -> IO a -> IO a
topHandlerWith cont prog = do
-- By default, stderr to a terminal device is NoBuffering. But this
......@@ -402,7 +404,7 @@ topHandlerWith cont prog = do
Just ioe
| ioeGetVerbatim ioe ->
-- Use the message verbatim
ioeGetErrorString ioe
ioeGetErrorString ioe ++ "\n"
| isUserError ioe ->
let file = case ioeGetFileName ioe of
Nothing -> ""
......@@ -413,7 +415,7 @@ topHandlerWith cont prog = do
detail = ioeGetErrorString ioe
in wrapText (pname ++ ": " ++ file ++ detail)
_ ->
displaySomeException se
displaySomeException se ++ "\n"
-- | BC wrapper around 'Exception.displayException'.
displaySomeException :: Exception.Exception e => e -> String
......@@ -541,7 +543,7 @@ handleDoesNotExist e =
wrapTextVerbosity :: Verbosity -> String -> String
wrapTextVerbosity verb
| isVerboseNoWrap verb = withTrailingNewline
| otherwise = wrapText
| otherwise = withTrailingNewline . wrapText
-- | Wrap output with a marker if @+markoutput@ verbosity flag is set.
--
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment