{-# 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.DynamoDB.Types.FailureException
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DynamoDB.Types.FailureException where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DynamoDB.Types.AttributeValue
import Amazonka.DynamoDB.Types.WriteRequest
import qualified Amazonka.Prelude as Prelude

-- | Represents a failure a contributor insights operation.
--
-- /See:/ 'newFailureException' smart constructor.
data FailureException = FailureException'
  { -- | Description of the failure.
    FailureException -> Maybe Text
exceptionDescription :: Prelude.Maybe Prelude.Text,
    -- | Exception name.
    FailureException -> Maybe Text
exceptionName :: Prelude.Maybe Prelude.Text
  }
  deriving (FailureException -> FailureException -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailureException -> FailureException -> Bool
$c/= :: FailureException -> FailureException -> Bool
== :: FailureException -> FailureException -> Bool
$c== :: FailureException -> FailureException -> Bool
Prelude.Eq, ReadPrec [FailureException]
ReadPrec FailureException
Int -> ReadS FailureException
ReadS [FailureException]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailureException]
$creadListPrec :: ReadPrec [FailureException]
readPrec :: ReadPrec FailureException
$creadPrec :: ReadPrec FailureException
readList :: ReadS [FailureException]
$creadList :: ReadS [FailureException]
readsPrec :: Int -> ReadS FailureException
$creadsPrec :: Int -> ReadS FailureException
Prelude.Read, Int -> FailureException -> ShowS
[FailureException] -> ShowS
FailureException -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailureException] -> ShowS
$cshowList :: [FailureException] -> ShowS
show :: FailureException -> String
$cshow :: FailureException -> String
showsPrec :: Int -> FailureException -> ShowS
$cshowsPrec :: Int -> FailureException -> ShowS
Prelude.Show, forall x. Rep FailureException x -> FailureException
forall x. FailureException -> Rep FailureException x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailureException x -> FailureException
$cfrom :: forall x. FailureException -> Rep FailureException x
Prelude.Generic)

-- |
-- Create a value of 'FailureException' 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:
--
-- 'exceptionDescription', 'failureException_exceptionDescription' - Description of the failure.
--
-- 'exceptionName', 'failureException_exceptionName' - Exception name.
newFailureException ::
  FailureException
newFailureException :: FailureException
newFailureException =
  FailureException'
    { $sel:exceptionDescription:FailureException' :: Maybe Text
exceptionDescription =
        forall a. Maybe a
Prelude.Nothing,
      $sel:exceptionName:FailureException' :: Maybe Text
exceptionName = forall a. Maybe a
Prelude.Nothing
    }

-- | Description of the failure.
failureException_exceptionDescription :: Lens.Lens' FailureException (Prelude.Maybe Prelude.Text)
failureException_exceptionDescription :: Lens' FailureException (Maybe Text)
failureException_exceptionDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureException' {Maybe Text
exceptionDescription :: Maybe Text
$sel:exceptionDescription:FailureException' :: FailureException -> Maybe Text
exceptionDescription} -> Maybe Text
exceptionDescription) (\s :: FailureException
s@FailureException' {} Maybe Text
a -> FailureException
s {$sel:exceptionDescription:FailureException' :: Maybe Text
exceptionDescription = Maybe Text
a} :: FailureException)

-- | Exception name.
failureException_exceptionName :: Lens.Lens' FailureException (Prelude.Maybe Prelude.Text)
failureException_exceptionName :: Lens' FailureException (Maybe Text)
failureException_exceptionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureException' {Maybe Text
exceptionName :: Maybe Text
$sel:exceptionName:FailureException' :: FailureException -> Maybe Text
exceptionName} -> Maybe Text
exceptionName) (\s :: FailureException
s@FailureException' {} Maybe Text
a -> FailureException
s {$sel:exceptionName:FailureException' :: Maybe Text
exceptionName = Maybe Text
a} :: FailureException)

instance Data.FromJSON FailureException where
  parseJSON :: Value -> Parser FailureException
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FailureException"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> FailureException
FailureException'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ExceptionDescription")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ExceptionName")
      )

instance Prelude.Hashable FailureException where
  hashWithSalt :: Int -> FailureException -> Int
hashWithSalt Int
_salt FailureException' {Maybe Text
exceptionName :: Maybe Text
exceptionDescription :: Maybe Text
$sel:exceptionName:FailureException' :: FailureException -> Maybe Text
$sel:exceptionDescription:FailureException' :: FailureException -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
exceptionDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
exceptionName

instance Prelude.NFData FailureException where
  rnf :: FailureException -> ()
rnf FailureException' {Maybe Text
exceptionName :: Maybe Text
exceptionDescription :: Maybe Text
$sel:exceptionName:FailureException' :: FailureException -> Maybe Text
$sel:exceptionDescription:FailureException' :: FailureException -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
exceptionDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
exceptionName