Revision 707cd3d7 htools/Ganeti/Utils.hs

b/htools/Ganeti/Utils.hs
213 213
-- | Unwraps a 'Result', exiting the program if it is a 'Bad' value,
214 214
-- otherwise returning the actual contained value.
215 215
exitIfBad :: String -> Result a -> IO a
216
exitIfBad msg (Bad s) = do
217
  hPutStrLn stderr $ "Error: " ++ msg ++ ": " ++ s
218
  exitWith (ExitFailure 1)
216
exitIfBad msg (Bad s) = exitErr (msg ++ ": " ++ s)
219 217
exitIfBad _ (Ok v) = return v
220 218

  
221 219
-- | Exits immediately with an error message.
222 220
exitErr :: String -> IO a
223 221
exitErr errmsg = do
224
  hPutStrLn stderr $ "Error: " ++ errmsg ++ "."
222
  hPutStrLn stderr $ "Error: " ++ errmsg
225 223
  exitWith (ExitFailure 1)
226 224

  
227 225
-- | Exits with an error message if the given boolean condition if true.

Also available in: Unified diff