diff options
author | 2018-02-19 15:28:38 -0400 | |
---|---|---|
committer | 2018-02-19 15:28:38 -0400 | |
commit | e8626258f0422fb6487e79c58e5f10d51a3c1737 (patch) | |
tree | f7369bff2ce3716849438f9799d8be1e94a72e8c /Messages/Internal.hs | |
parent | 7f49e1b922d83fa6548c4c9357591b661cbf1c46 (diff) |
send stderr to json when --json-error-messages enabled
Diffstat (limited to 'Messages/Internal.hs')
-rw-r--r-- | Messages/Internal.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Messages/Internal.hs b/Messages/Internal.hs index 3731af16d..734b146b3 100644 --- a/Messages/Internal.hs +++ b/Messages/Internal.hs @@ -60,10 +60,14 @@ outputJSON jsonbuilder s = case outputType s of _ -> return False outputError :: String -> Annex () -outputError msg = withMessageState $ \s -> - if concurrentOutputEnabled s - then concurrentMessage s True msg go - else go +outputError msg = withMessageState $ \s -> case (outputType s, jsonBuffer s) of + (JSONOutput jsonoptions, Just jb) | jsonErrorMessages jsonoptions -> + let jb' = Just (JSON.addErrorMessage [msg] jb) + in Annex.changeState $ \st -> + st { Annex.output = s { jsonBuffer = jb' } + _ + | concurrentOutputEnabled s -> concurrentMessage s True msg go + | otherwise -> go where go = liftIO $ do hFlush stdout |