Revision 9491766c src/Ganeti/Errors.hs

b/src/Ganeti/Errors.hs
37 37
  , errorExitCode
38 38
  , excName
39 39
  , formatError
40
  , maybeToError
40 41
  ) where
41 42

  
42 43
import Text.JSON hiding (Result, Ok)
......
177 178
errToResult :: ErrorResult a -> Result a
178 179
errToResult (Ok a)  = Ok a
179 180
errToResult (Bad e) = Bad $ formatError e
181

  
182
-- | Convert from a 'Maybe' to a an 'ErrorResult'.
183
maybeToError :: String -> Maybe a -> ErrorResult a
184
maybeToError _ (Just a) = Ok a
185
maybeToError m  Nothing = Bad $ GenericError m

Also available in: Unified diff