( ErrorCode(..)
, GanetiException(..)
, ErrorResult
- , excName
+ , errToResult
, errorExitCode
+ , excName
, formatError
) where
$(declareSADT "ErrorCode"
[ ("ECodeResolver", 'C.errorsEcodeResolver)
, ("ECodeNoRes", 'C.errorsEcodeNores)
+ , ("ECodeTempNoRes", 'C.errorsEcodeTempNores)
, ("ECodeInval", 'C.errorsEcodeInval)
, ("ECodeState", 'C.errorsEcodeState)
, ("ECodeNoEnt", 'C.errorsEcodeNoent)
, ("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