Use QueryFailure
instead of adding a new error to make the change backwards compatible
This commit is contained in:
parent
c6a9ffcc63
commit
951109c91d
1 changed files with 2 additions and 3 deletions
|
@ -130,7 +130,6 @@ data Failure =
|
||||||
| WriteConcernFailure Int String -- ^ Write concern error. It's reported only by insert, update, delete commands. Not by wire protocol.
|
| WriteConcernFailure Int String -- ^ Write concern error. It's reported only by insert, update, delete commands. Not by wire protocol.
|
||||||
| DocNotFound Selection -- ^ 'fetch' found no document matching selection
|
| DocNotFound Selection -- ^ 'fetch' found no document matching selection
|
||||||
| AggregateFailure String -- ^ 'aggregate' returned an error
|
| AggregateFailure String -- ^ 'aggregate' returned an error
|
||||||
| FindFailure String -- ^ 'find' returned an error
|
|
||||||
| CompoundFailure [Failure] -- ^ When we need to aggregate several failures and report them.
|
| CompoundFailure [Failure] -- ^ When we need to aggregate several failures and report them.
|
||||||
| ProtocolFailure Int String -- ^ The structure of the returned documents doesn't match what we expected
|
| ProtocolFailure Int String -- ^ The structure of the returned documents doesn't match what we expected
|
||||||
deriving (Show, Eq, Typeable)
|
deriving (Show, Eq, Typeable)
|
||||||
|
@ -1051,7 +1050,7 @@ findCommand Query{..} = do
|
||||||
]
|
]
|
||||||
|
|
||||||
getCursorFromResponse aColl response
|
getCursorFromResponse aColl response
|
||||||
>>= either (liftIO . throwIO . FindFailure) return
|
>>= either (liftIO . throwIO . QueryFailure (at "code" response)) return
|
||||||
|
|
||||||
where
|
where
|
||||||
toInt32 :: Integral a => a -> Int32
|
toInt32 :: Integral a => a -> Int32
|
||||||
|
@ -1350,7 +1349,7 @@ aggregateCursor :: (MonadIO m, MonadFail m) => Collection -> Pipeline -> Aggrega
|
||||||
aggregateCursor aColl agg _ = do
|
aggregateCursor aColl agg _ = do
|
||||||
response <- runCommand ["aggregate" =: aColl, "pipeline" =: agg, "cursor" =: ([] :: Document)]
|
response <- runCommand ["aggregate" =: aColl, "pipeline" =: agg, "cursor" =: ([] :: Document)]
|
||||||
getCursorFromResponse aColl response
|
getCursorFromResponse aColl response
|
||||||
>>= either (liftIO . throwIO . AggregateFailure) return
|
>>= either (liftIO . throwIO . AggregateFailure) return
|
||||||
|
|
||||||
getCursorFromResponse
|
getCursorFromResponse
|
||||||
:: (MonadIO m, MonadFail m)
|
:: (MonadIO m, MonadFail m)
|
||||||
|
|
Loading…
Reference in a new issue