Commit c1de9a76 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Improve error display in top level handler.



I noticed that in some cases we weren't adding a trailing
newline to error messages arising from "error"; this
patch adds a few newlines where there were none to solve
the problem.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent e1cdb90f
......@@ -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