Use QueryFailure instead of adding a new error to make the change backwards compatible

This commit is contained in:
Diego Balseiro 2020-08-11 16:46:28 -05:00
parent c6a9ffcc63
commit 951109c91d

View file

@ -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.
| DocNotFound Selection -- ^ 'fetch' found no document matching selection
| AggregateFailure String -- ^ 'aggregate' returned an error
| FindFailure String -- ^ 'find' returned an error
| 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
deriving (Show, Eq, Typeable)
@ -1051,7 +1050,7 @@ findCommand Query{..} = do
]
getCursorFromResponse aColl response
>>= either (liftIO . throwIO . FindFailure) return
>>= either (liftIO . throwIO . QueryFailure (at "code" response)) return
where
toInt32 :: Integral a => a -> Int32