fix reversion in display of fatal exceptions
authorJoey Hess <joeyh@joeyh.name>
Mon, 1 May 2023 16:25:14 +0000 (12:25 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 1 May 2023 16:25:14 +0000 (12:25 -0400)
fdac66ae10a7022326d1470862c93fd191216e61 lost the "git-annex:" prefix,
which broke datalad's parsing of an error message (ugh)

Also, don't use warningIO because it displays a blank line to stdout,
which is also a behavior change from before, and does not seem
necessary.

Sponsored-by: Brock Spratlen on Patreon
Messages.hs

index feb2fe4993787ae14ef5c9fec055f218a6008230..2fdfffc863e45bda9652e495f87c07eae58ecb2f 100644 (file)
@@ -60,6 +60,7 @@ import qualified Data.ByteString as S
 import qualified Data.ByteString.Char8 as S8
 import System.Exit
 import qualified Control.Monad.Catch as M
+import Data.String
 
 import Common
 import Types
@@ -200,8 +201,8 @@ endResult :: Bool -> S.ByteString
 endResult True = "ok"
 endResult False = "failed"
 
-toplevelMsg :: StringContainingQuotedPath -> StringContainingQuotedPath
-toplevelMsg = ("git-annex: " <>)
+toplevelMsg :: (Semigroup t, IsString t) => t -> t
+toplevelMsg s = fromString "git-annex: " <> s
 
 toplevelFileProblem :: Bool -> MessageId -> StringContainingQuotedPath -> String -> RawFilePath -> Maybe Key -> SeekInput -> Annex ()
 toplevelFileProblem makeway messageid msg action file mkey si = do
@@ -353,5 +354,5 @@ sanitizeTopLevelExceptionMessages a = a `catches`
        ((M.Handler (\ (e :: ExitCode) -> throwM e)) : nonAsyncHandler go)
   where
        go e = do
-               warningIO (show e)
+               hPutStrLn stderr $ safeOutput $ toplevelMsg (show e)
                exitWith $ ExitFailure 1