Skip to content

Instantly share code, notes, and snippets.

@sevanspowell
Created July 2, 2019 06:57
Show Gist options
  • Save sevanspowell/f728a4ee02d0beedcf365ecf17f16ef4 to your computer and use it in GitHub Desktop.
Save sevanspowell/f728a4ee02d0beedcf365ecf17f16ef4 to your computer and use it in GitHub Desktop.
Wrapping prismatic errors
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