( ErrorCode(..)
, GanetiException(..)
, ErrorResult
- , excName
+ , errToResult
, errorExitCode
+ , excName
, formatError
) where
, ("UnitParseError", [excErrMsg])
, ("ParseError", [excErrMsg])
, ("TypeEnforcementError", [excErrMsg])
- , ("X509CertError", [excErrMsg])
+ , ("X509CertError", [ ("certFileName", [t| String |])
+ , excErrMsg ])
, ("TagError", [excErrMsg])
, ("CommandError", [excErrMsg])
, ("StorageError", [excErrMsg])
"Unhandled Ganeti error: " ++ msg
formatError err =
"Unhandled exception: " ++ show err
+
+-- | Convert from an 'ErrorResult' to a standard 'Result'.
+errToResult :: ErrorResult a -> Result a
+errToResult (Ok a) = Ok a
+errToResult (Bad e) = Bad $ formatError e