Revision 9491766c src/Ganeti/Query/Common.hs

b/src/Ganeti/Query/Common.hs
30 30
  , rsNormal
31 31
  , rsMaybeNoData
32 32
  , rsMaybeUnavail
33
  , rsErrorNoData
33 34
  , rsUnknown
34 35
  , missingRuntime
35 36
  , rpcErrorToStatus
......
47 48
import Data.Maybe (fromMaybe)
48 49
import Text.JSON (JSON, showJSON)
49 50

  
51
import Ganeti.BasicTypes
50 52
import qualified Ganeti.Constants as C
51 53
import Ganeti.Config
54
import Ganeti.Errors
52 55
import Ganeti.JSON
53 56
import Ganeti.Objects
54 57
import Ganeti.Rpc
......
92 95
rsMaybeNoData :: (JSON a) => Maybe a -> ResultEntry
93 96
rsMaybeNoData = maybe rsNoData rsNormal
94 97

  
98
-- | Helper to declare a result from a 'ErrorResult' (an error happened
99
-- while retrieving the data from a config, or there was no data).
100
-- This function should be used if an error signals there was no data.
101
rsErrorNoData :: (JSON a) => ErrorResult a -> ResultEntry
102
rsErrorNoData res = case res of
103
  Ok  x -> rsNormal x
104
  Bad _ -> rsNoData
105

  
95 106
-- | Helper to declare a result from a 'Maybe'. This version returns
96 107
-- a 'RSUnavail' in case of 'Nothing'. It should be used for optional
97 108
-- fields that are not set. For cases where 'Nothing' means that there

Also available in: Unified diff