77-- Portability : non-portable (GHC extensions)
88module Amazonka.Error where
99
10- import Amazonka.Core.Lens.Internal (Choice , Fold , Optic ' , filtered )
10+ import Amazonka.Core.Lens.Internal (Fold , LensLike ' , filtered )
1111import Amazonka.Data
1212import Amazonka.Prelude
1313import Amazonka.Types
@@ -40,7 +40,7 @@ import Network.HTTP.Types.Status (Status (..))
4040-- >>> :t trying _NoSuchBucketPolicy
4141-- MonadCatch m => m a -> m (Either ServiceError a)
4242_MatchServiceError ::
43- AsError a =>
43+ ( AsError a ) =>
4444 Service ->
4545 ErrorCode ->
4646 Fold a ServiceError
@@ -49,7 +49,7 @@ _MatchServiceError s c = _ServiceError . hasService s . hasCode c
4949statusSuccess :: Status -> Bool
5050statusSuccess (statusCode -> n) = n >= 200 && n < 300 || n == 304
5151
52- _HttpStatus :: AsError a => Traversal' a Status
52+ _HttpStatus :: ( AsError a ) => Traversal' a Status
5353_HttpStatus = _Error . f
5454 where
5555 f g = \ case
@@ -67,21 +67,21 @@ _HttpStatus = _Error . f
6767 (\ x -> ServiceError (e {status = x})) <$> g status
6868
6969hasService ::
70- (Applicative f , Choice p ) =>
70+ (Applicative f ) =>
7171 Service ->
72- Optic' p f ServiceError ServiceError
72+ LensLike' f ServiceError ServiceError
7373hasService Service {abbrev} = filtered ((abbrev == ) . ServiceError. abbrev)
7474
7575hasStatus ::
76- (Applicative f , Choice p ) =>
76+ (Applicative f ) =>
7777 Int ->
78- Optic' p f ServiceError ServiceError
78+ LensLike' f ServiceError ServiceError
7979hasStatus n = filtered ((n == ) . fromEnum . ServiceError. status)
8080
8181hasCode ::
82- (Applicative f , Choice p ) =>
82+ (Applicative f ) =>
8383 ErrorCode ->
84- Optic' p f ServiceError ServiceError
84+ LensLike' f ServiceError ServiceError
8585hasCode c = filtered ((c == ) . ServiceError. code)
8686
8787serviceError ::
@@ -134,9 +134,7 @@ parseJSONError a s h bs =
134134 msg c o =
135135 if c == Just " RequestEntityTooLarge"
136136 then pure (Just " Request body must be less than 1 MB" )
137- else
138- Just <$> o .: " message"
139- <|> o .:? " Message"
137+ else Just <$> o .: " message" <|> o .:? " Message"
140138
141139parseXMLError ::
142140 Abbrev ->
0 commit comments