libZSamazonka-coreZSamazonka-core
Copyright(c) 2013-2021 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone

Amazonka.Error

Description

 
Synopsis

Documentation

_MatchServiceError :: AsError a => Service -> ErrorCode -> Getting (First ServiceError) a ServiceError Source #

Provides a generalised prism for catching a specific service error identified by the opaque service abbreviation and error code.

This can be used if the generated error prisms provided by Amazonka.ServiceName.Types do not cover all the thrown error codes. For example to define a new error prism:

{-# LANGUAGE OverloadedStrings #-}

import Amazonka.S3 (ServiceError, s3)

_NoSuchBucketPolicy :: AsError a => Getting (First ServiceError) a ServiceError
_NoSuchBucketPolicy = _MatchServiceError s3 "NoSuchBucketPolicy"

With example usage being:

>>> import Control.Exception.Lens (trying)
>>> :t trying _NoSuchBucketPolicy
MonadCatch m => m a -> m (Either ServiceError a)