From 951109c91d09807c0c32486e1815f9c001e036ae Mon Sep 17 00:00:00 2001 From: Diego Balseiro Date: Tue, 11 Aug 2020 16:46:28 -0500 Subject: [PATCH] Use `QueryFailure` instead of adding a new error to make the change backwards compatible --- Database/MongoDB/Query.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Database/MongoDB/Query.hs b/Database/MongoDB/Query.hs index 9f1a7ae..1d76de0 100644 --- a/Database/MongoDB/Query.hs +++ b/Database/MongoDB/Query.hs @@ -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 @@ -1350,7 +1349,7 @@ aggregateCursor :: (MonadIO m, MonadFail m) => Collection -> Pipeline -> Aggrega aggregateCursor aColl agg _ = do response <- runCommand ["aggregate" =: aColl, "pipeline" =: agg, "cursor" =: ([] :: Document)] getCursorFromResponse aColl response - >>= either (liftIO . throwIO . AggregateFailure) return + >>= either (liftIO . throwIO . AggregateFailure) return getCursorFromResponse :: (MonadIO m, MonadFail m)