{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.FinSpaceData.Types.ErrorInfo
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.FinSpaceData.Types.ErrorInfo where

import qualified Amazonka.Core as Core
import Amazonka.FinSpaceData.Types.ErrorCategory
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Error message.
--
-- /See:/ 'newErrorInfo' smart constructor.
data ErrorInfo = ErrorInfo'
  { -- | The category of the error.
    --
    -- -   @VALIDATION@ -The inputs to this request are invalid.
    --
    -- -   @SERVICE_QUOTA_EXCEEDED@ - Service quotas have been exceeded. Please
    --     contact AWS support to increase quotas.
    --
    -- -   @ACCESS_DENIED@ - Missing required permission to perform this
    --     request.
    --
    -- -   @RESOURCE_NOT_FOUND@ - One or more inputs to this request were not
    --     found.
    --
    -- -   @THROTTLING@ - The system temporarily lacks sufficient resources to
    --     process the request.
    --
    -- -   @INTERNAL_SERVICE_EXCEPTION@ - An internal service error has
    --     occurred.
    --
    -- -   @CANCELLED@ - A user recoverable error has occurred.
    ErrorInfo -> Maybe ErrorCategory
errorCategory :: Prelude.Maybe ErrorCategory,
    -- | The text of the error message.
    ErrorInfo -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (ErrorInfo -> ErrorInfo -> Bool
(ErrorInfo -> ErrorInfo -> Bool)
-> (ErrorInfo -> ErrorInfo -> Bool) -> Eq ErrorInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorInfo -> ErrorInfo -> Bool
$c/= :: ErrorInfo -> ErrorInfo -> Bool
== :: ErrorInfo -> ErrorInfo -> Bool
$c== :: ErrorInfo -> ErrorInfo -> Bool
Prelude.Eq, ReadPrec [ErrorInfo]
ReadPrec ErrorInfo
Int -> ReadS ErrorInfo
ReadS [ErrorInfo]
(Int -> ReadS ErrorInfo)
-> ReadS [ErrorInfo]
-> ReadPrec ErrorInfo
-> ReadPrec [ErrorInfo]
-> Read ErrorInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorInfo]
$creadListPrec :: ReadPrec [ErrorInfo]
readPrec :: ReadPrec ErrorInfo
$creadPrec :: ReadPrec ErrorInfo
readList :: ReadS [ErrorInfo]
$creadList :: ReadS [ErrorInfo]
readsPrec :: Int -> ReadS ErrorInfo
$creadsPrec :: Int -> ReadS ErrorInfo
Prelude.Read, Int -> ErrorInfo -> ShowS
[ErrorInfo] -> ShowS
ErrorInfo -> String
(Int -> ErrorInfo -> ShowS)
-> (ErrorInfo -> String)
-> ([ErrorInfo] -> ShowS)
-> Show ErrorInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorInfo] -> ShowS
$cshowList :: [ErrorInfo] -> ShowS
show :: ErrorInfo -> String
$cshow :: ErrorInfo -> String
showsPrec :: Int -> ErrorInfo -> ShowS
$cshowsPrec :: Int -> ErrorInfo -> ShowS
Prelude.Show, (forall x. ErrorInfo -> Rep ErrorInfo x)
-> (forall x. Rep ErrorInfo x -> ErrorInfo) -> Generic ErrorInfo
forall x. Rep ErrorInfo x -> ErrorInfo
forall x. ErrorInfo -> Rep ErrorInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorInfo x -> ErrorInfo
$cfrom :: forall x. ErrorInfo -> Rep ErrorInfo x
Prelude.Generic)

-- |
-- Create a value of 'ErrorInfo' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'errorCategory', 'errorInfo_errorCategory' - The category of the error.
--
-- -   @VALIDATION@ -The inputs to this request are invalid.
--
-- -   @SERVICE_QUOTA_EXCEEDED@ - Service quotas have been exceeded. Please
--     contact AWS support to increase quotas.
--
-- -   @ACCESS_DENIED@ - Missing required permission to perform this
--     request.
--
-- -   @RESOURCE_NOT_FOUND@ - One or more inputs to this request were not
--     found.
--
-- -   @THROTTLING@ - The system temporarily lacks sufficient resources to
--     process the request.
--
-- -   @INTERNAL_SERVICE_EXCEPTION@ - An internal service error has
--     occurred.
--
-- -   @CANCELLED@ - A user recoverable error has occurred.
--
-- 'errorMessage', 'errorInfo_errorMessage' - The text of the error message.
newErrorInfo ::
  ErrorInfo
newErrorInfo :: ErrorInfo
newErrorInfo =
  ErrorInfo' :: Maybe ErrorCategory -> Maybe Text -> ErrorInfo
ErrorInfo'
    { $sel:errorCategory:ErrorInfo' :: Maybe ErrorCategory
errorCategory = Maybe ErrorCategory
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:ErrorInfo' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The category of the error.
--
-- -   @VALIDATION@ -The inputs to this request are invalid.
--
-- -   @SERVICE_QUOTA_EXCEEDED@ - Service quotas have been exceeded. Please
--     contact AWS support to increase quotas.
--
-- -   @ACCESS_DENIED@ - Missing required permission to perform this
--     request.
--
-- -   @RESOURCE_NOT_FOUND@ - One or more inputs to this request were not
--     found.
--
-- -   @THROTTLING@ - The system temporarily lacks sufficient resources to
--     process the request.
--
-- -   @INTERNAL_SERVICE_EXCEPTION@ - An internal service error has
--     occurred.
--
-- -   @CANCELLED@ - A user recoverable error has occurred.
errorInfo_errorCategory :: Lens.Lens' ErrorInfo (Prelude.Maybe ErrorCategory)
errorInfo_errorCategory :: (Maybe ErrorCategory -> f (Maybe ErrorCategory))
-> ErrorInfo -> f ErrorInfo
errorInfo_errorCategory = (ErrorInfo -> Maybe ErrorCategory)
-> (ErrorInfo -> Maybe ErrorCategory -> ErrorInfo)
-> Lens
     ErrorInfo ErrorInfo (Maybe ErrorCategory) (Maybe ErrorCategory)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorInfo' {Maybe ErrorCategory
errorCategory :: Maybe ErrorCategory
$sel:errorCategory:ErrorInfo' :: ErrorInfo -> Maybe ErrorCategory
errorCategory} -> Maybe ErrorCategory
errorCategory) (\s :: ErrorInfo
s@ErrorInfo' {} Maybe ErrorCategory
a -> ErrorInfo
s {$sel:errorCategory:ErrorInfo' :: Maybe ErrorCategory
errorCategory = Maybe ErrorCategory
a} :: ErrorInfo)

-- | The text of the error message.
errorInfo_errorMessage :: Lens.Lens' ErrorInfo (Prelude.Maybe Prelude.Text)
errorInfo_errorMessage :: (Maybe Text -> f (Maybe Text)) -> ErrorInfo -> f ErrorInfo
errorInfo_errorMessage = (ErrorInfo -> Maybe Text)
-> (ErrorInfo -> Maybe Text -> ErrorInfo)
-> Lens ErrorInfo ErrorInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorInfo' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:ErrorInfo' :: ErrorInfo -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: ErrorInfo
s@ErrorInfo' {} Maybe Text
a -> ErrorInfo
s {$sel:errorMessage:ErrorInfo' :: Maybe Text
errorMessage = Maybe Text
a} :: ErrorInfo)

instance Core.FromJSON ErrorInfo where
  parseJSON :: Value -> Parser ErrorInfo
parseJSON =
    String -> (Object -> Parser ErrorInfo) -> Value -> Parser ErrorInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ErrorInfo"
      ( \Object
x ->
          Maybe ErrorCategory -> Maybe Text -> ErrorInfo
ErrorInfo'
            (Maybe ErrorCategory -> Maybe Text -> ErrorInfo)
-> Parser (Maybe ErrorCategory) -> Parser (Maybe Text -> ErrorInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ErrorCategory)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errorCategory")
            Parser (Maybe Text -> ErrorInfo)
-> Parser (Maybe Text) -> Parser ErrorInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errorMessage")
      )

instance Prelude.Hashable ErrorInfo

instance Prelude.NFData ErrorInfo