( ErrorCode(..)
, GanetiException(..)
, ErrorResult
- , excName
+ , errToResult
, errorExitCode
+ , excName
, formatError
) where
, ("ProgrammerError", [excErrMsg])
, ("BlockDeviceError", [excErrMsg])
, ("ConfigurationError", [excErrMsg])
- , ("ConfigVersionMismatch", [ ("expCode", [t| Int |])
- , ("actCode", [t| Int |])])
+ , ("ConfigVersionMismatch", [ ("expVer", [t| Int |])
+ , ("actVer", [t| Int |])])
, ("ReservationError", [excErrMsg])
, ("RemoteError", [excErrMsg])
, ("SignatureError", [excErrMsg])
, ("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