Created
July 2, 2019 06:57
-
-
Save sevanspowell/f728a4ee02d0beedcf365ecf17f16ef4 to your computer and use it in GitHub Desktop.
Wrapping prismatic errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data WrapperError = WrappingS3Error S3Error | |
makeClassyPrisms ''WrapperError | |
instance AsS3Error WrapperError where | |
_S3Error = _WrappingS3Error | |
inner | |
:: ( AWS.MonadAWS m | |
, MonadError e m | |
, AsS3Error e | |
, MonadResource m | |
) | |
=> m S3.GetObjectResponse | |
inner = getObjectResponse "bucket" "key" | |
wrapper | |
:: ( AWS.MonadAWS m | |
, MonadError e m | |
, AsWrapperError e | |
, MonadResource m | |
) | |
=> m S3.GetObjectResponse | |
wrapper = do | |
(e :: Either S3Error S3.GetObjectResponse) <- runExceptT inner | |
either (throwing _WrappingS3Error) pure e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment