packages feed

serverless-haskell 0.12.2 → 0.12.3

raw patch · 2 files changed

+13/−5 lines, 2 files

Files

serverless-haskell.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: eb3183c0aeb30569bc69a5ef32f4f467d305108dd464c3f86d33b56507b3af46+-- hash: 137eaceeb74935a6ac010d0b06486fde175ceedf641d181bd0371d6579587d5d  name:           serverless-haskell-version:        0.12.2+version:        0.12.3 synopsis:       Deploying Haskell code onto AWS Lambda using Serverless description:    Utilities to help process the events from AWS Lambda when deployed with the serverless-haskell plugin. category:       AWS, Cloud, Network
src/AWSLambda/Handler.hs view
@@ -115,12 +115,17 @@         resultOrError <- tryAny $ act input         case resultOrError of           Right result   -> liftIO $ void $ httpNoBody (resultRequest address requestId result) manager-          Left exception -> liftIO $ void $ httpNoBody (errorRequest address requestId exception) manager+          Left exception -> do+            putStrLnLBS $ Aeson.encode $ exceptionJSON exception+            liftIO $ void $ httpNoBody (errorRequest address requestId exception) manager     Nothing -> do       input <- liftIO $ LBS.fromStrict <$> ByteString.getLine       result <- act input-      liftIO $ Text.putStrLn $ Text.decodeUtf8 $ LBS.toStrict result+      putStrLnLBS result +putStrLnLBS :: MonadIO m => LBS.ByteString -> m ()+putStrLnLBS = liftIO . Text.putStrLn . Text.decodeUtf8 . LBS.toStrict+ lambdaApiAddressEnv :: String lambdaApiAddressEnv = "AWS_LAMBDA_RUNTIME_API" @@ -136,7 +141,10 @@ errorRequest :: String -> String -> SomeException -> Request errorRequest apiAddress requestId exception = (lambdaRequest apiAddress $ "/runtime/invocation/" ++ requestId ++ "/error") { method = "POST", requestBody = RequestBodyLBS body }   where-    body = Aeson.encode $ Aeson.object [ "errorMessage" .= displayException exception, "errorType" .= exceptionType exception]+    body = Aeson.encode $ exceptionJSON exception++exceptionJSON :: SomeException -> Aeson.Value+exceptionJSON exception = Aeson.object [ "errorMessage" .= displayException exception, "errorType" .= exceptionType exception]  exceptionType :: SomeException -> String exceptionType (SomeException e) = show (typeOf e)