git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: fix some issues with brief errors
commit33ad122e48d47fb7180029d4c2d31acb46769907 authorAndy Arvanitis <andyarvanitis@gmail.com> dateTue 13 Dec 2016, 16:41 (10 years ago) parent8b15a23
1 file changed+19−16
pcc/Main.hs+19−16
pcc/Main.hs+19−16
@@ -31,6 +31,7 @@ import qualified Data.ByteString.Lazy as B
3131import qualified Data.ByteString.UTF8 as BU8
3232import Data.Char (isSpace)
3333import qualified Data.Map as M
34+import Data.Maybe (maybe)
3435import Data.Text (Text)
3536import Data.Version (showVersion)
3637
@@ -97,28 +98,30 @@ printWarningsAndErrors verbose BriefErrors warnings errors = do
9798 either (const exitFailure) (const (return ())) errors
9899
99100briefFormat :: JSONResult -> [String]
100−briefFormat (JSONResult warnings errors) = concat $
101+briefFormat (JSONResult warnings errors) =
101102 (renderError Error <$> errors) <> (renderError Warning <$> warnings)
102103 where
103− renderError :: BriefType -> JSONError -> [String]
104− renderError t (JSONError pos msg _ lnk file _ suggest) =
104+ renderError :: BriefType -> JSONError -> String
105+ renderError t (JSONError (Just pos) msg _ lnk (Just file) _ _) =
105106 printf
106107 "%s:%d:%d: %s: %s"
107− (concat file)
108− (maybe 0 startLine pos)
109− (maybe 0 startColumn pos)
108+ file
109+ (startLine pos)
110+ (startColumn pos)
110111 (show t)
111− (dropWhile isSpace message) :
112− notes
112+ (combine msg lnk)
113+ renderError t (JSONError _ msg _ lnk _ module' _) =
114+ printf
115+ "%s: in module %s - %s"
116+ (show t)
117+ (maybe "?" (printf "\"%s\"") module')
118+ (combine msg lnk)
119+ combine :: String -> String -> String
120+ combine msg lnk
121+ | null lnk = msg'
122+ | otherwise = printf "%s\nSee %s for more information\n" msg' lnk
113123 where
114− message
115− | null lnk = msg
116− | otherwise = printf "%s\nSee %s for more information\n" msg lnk
117− notes
118− | Error <- t,
119− Just (ErrorSuggestion s@(_:_) r) <- suggest =
120− renderError Note (JSONError (r <|> pos) s [] [] file Nothing Nothing)
121− | otherwise = []
124+ msg' = dropWhile isSpace msg
122125
123126compile :: PCCMakeOptions -> IO ()
124127compile PCCMakeOptions{..} = do