packages feed

antiope-core 6.1.3 → 6.1.4

raw patch · 2 files changed

+29/−2 lines, 2 filesdep +exceptionsdep +http-typesPVP ok

version bump matches the API change (PVP)

Dependencies added: exceptions, http-types

API changes (from Hackage documentation)

+ Antiope.Core.Error: handle404ToNone :: MonadAWS m => m a -> m (Maybe a)

Files

antiope-core.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: e43ecb88a209266883977d64d766cb81e588268747897a9fdb6d2deb846f36d1+-- hash: 49d3954b7ca5d249a62dc367c7c8c2b64ef67819769acc7855ef3b3173072a0b  name:           antiope-core-version:        6.1.3+version:        6.1.4 description:    Please see the README on Github at <https://github.com/arbor/antiope#readme> category:       Services homepage:       https://github.com/arbor/antiope#readme@@ -28,6 +28,7 @@ library   exposed-modules:       Antiope.Core+      Antiope.Core.Error       Antiope.Env       Antiope.Orphans   other-modules:@@ -40,8 +41,10 @@     , amazonka-core     , base >=4.7 && <5     , bytestring+    , exceptions     , generic-lens     , http-client+    , http-types     , lens     , monad-logger     , mtl@@ -64,8 +67,10 @@     , antiope-core     , base >=4.7 && <5     , bytestring+    , exceptions     , generic-lens     , http-client+    , http-types     , lens     , monad-logger     , mtl
+ src/Antiope/Core/Error.hs view
@@ -0,0 +1,22 @@+{-# LANGUAGE ScopedTypeVariables #-}++module Antiope.Core.Error+  ( handle404ToNone+  ) where++import Control.Monad.Catch       (catch, throwM)+import Network.AWS               (Error (..), MonadAWS, ServiceError (..))+import Network.HTTP.Types.Status (Status (..))++import qualified Data.ByteString.Lazy as LBS++handle404ToNone :: MonadAWS m+  => m a+  -> m (Maybe a)+handle404ToNone f = do+  ebs <- (Right <$> f) `catch` \(err :: Error) -> case err of+    (ServiceError (ServiceError' _ (Status 404 _) _ _ _ _)) -> return (Left LBS.empty)+    _                                                       -> throwM err+  case ebs of+    Right bs -> return (Just bs)+    Left _   -> return Nothing