Revision 62377cf5 htools/Ganeti/Qlang.hs

b/htools/Ganeti/Qlang.hs
35 35
    , FieldDefinition(..)
36 36
    , ResultEntry(..)
37 37
    , ItemType(..)
38
    , checkRS
38 39
    ) where
39 40

  
40 41
import Control.Applicative
......
58 59
  ])
59 60
$(makeJSONInstance ''ResultStatus)
60 61

  
62
-- | Check that ResultStatus is success or fail with descriptive
63
-- message.
64
checkRS :: (Monad m) => ResultStatus -> a -> m a
65
checkRS RSNormal val = return val
66
checkRS RSUnknown  _ = fail "Unknown field"
67
checkRS RSNoData   _ = fail "No data for a field"
68
checkRS RSUnavail  _ = fail "Ganeti reports unavailable data"
69
checkRS RSOffline  _ = fail "Ganeti reports resource as offline"
70

  
61 71
-- | Type of a query field.
62 72
$(declareSADT "FieldType"
63 73
  [ ("QFTUnknown",   'C.qftUnknown )

Also available in: Unified diff