diff --git a/htools/Ganeti/BasicTypes.hs b/htools/Ganeti/BasicTypes.hs index 149540fdb400e5a2fa81fd603ed4e8676232a669..f37a523352f8dafaf05fa2c99c8083e5280cde0f 100644 --- a/htools/Ganeti/BasicTypes.hs +++ b/htools/Ganeti/BasicTypes.hs @@ -31,7 +31,6 @@ module Ganeti.BasicTypes , isBad , eitherToResult , annotateResult - , annotateIOError , select , LookupResult(..) , MatchPriority(..) @@ -133,12 +132,6 @@ annotateResult :: String -> Result a -> Result a annotateResult owner (Bad s) = Bad $ owner ++ ": " ++ s annotateResult _ v = v --- | Annotates and transforms IOErrors into a Result type. This can be --- used in the error handler argument to 'catch', for example. -annotateIOError :: String -> IOError -> IO (Result a) -annotateIOError description exc = - return . Bad $ description ++ ": " ++ show exc - -- * Misc functionality -- | Return the first result with a True condition, or the default otherwise. diff --git a/htools/Ganeti/Daemon.hs b/htools/Ganeti/Daemon.hs index 0ac861a071db778147c1e27ee6ae76313bb4bc2f..51f08059a4d99f84195435de02c947f7cb6617bf 100644 --- a/htools/Ganeti/Daemon.hs +++ b/htools/Ganeti/Daemon.hs @@ -188,6 +188,12 @@ genericOpts = [ oShowHelp , oShowComp ] +-- | Annotates and transforms IOErrors into a Result type. This can be +-- used in the error handler argument to 'catch', for example. +ioErrorToResult :: String -> IOError -> IO (Result a) +ioErrorToResult description exc = + return . Bad $ description ++ ": " ++ show exc + -- | Small wrapper over getArgs and 'parseOpts'. parseArgs :: String -> [OptType] -> IO (DaemonOptions, [String]) parseArgs cmd options = do @@ -290,7 +296,7 @@ parseAddress opts defport = do Nothing -> return (def_family >>= defaultBindAddr port) Just saddr -> Control.Exception.catch (resolveAddr port saddr) - (annotateIOError $ "Invalid address " ++ saddr) + (ioErrorToResult $ "Invalid address " ++ saddr) -- | Run an I/O action as a daemon. --