{-# 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.CloudDirectory.Types.BatchReadException
-- 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.CloudDirectory.Types.BatchReadException where

import Amazonka.CloudDirectory.Types.BatchReadExceptionType
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The batch read exception structure, which contains the exception type
-- and message.
--
-- /See:/ 'newBatchReadException' smart constructor.
data BatchReadException = BatchReadException'
  { -- | An exception message that is associated with the failure.
    BatchReadException -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | A type of exception, such as @InvalidArnException@.
    BatchReadException -> Maybe BatchReadExceptionType
type' :: Prelude.Maybe BatchReadExceptionType
  }
  deriving (BatchReadException -> BatchReadException -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchReadException -> BatchReadException -> Bool
$c/= :: BatchReadException -> BatchReadException -> Bool
== :: BatchReadException -> BatchReadException -> Bool
$c== :: BatchReadException -> BatchReadException -> Bool
Prelude.Eq, ReadPrec [BatchReadException]
ReadPrec BatchReadException
Int -> ReadS BatchReadException
ReadS [BatchReadException]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchReadException]
$creadListPrec :: ReadPrec [BatchReadException]
readPrec :: ReadPrec BatchReadException
$creadPrec :: ReadPrec BatchReadException
readList :: ReadS [BatchReadException]
$creadList :: ReadS [BatchReadException]
readsPrec :: Int -> ReadS BatchReadException
$creadsPrec :: Int -> ReadS BatchReadException
Prelude.Read, Int -> BatchReadException -> ShowS
[BatchReadException] -> ShowS
BatchReadException -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchReadException] -> ShowS
$cshowList :: [BatchReadException] -> ShowS
show :: BatchReadException -> String
$cshow :: BatchReadException -> String
showsPrec :: Int -> BatchReadException -> ShowS
$cshowsPrec :: Int -> BatchReadException -> ShowS
Prelude.Show, forall x. Rep BatchReadException x -> BatchReadException
forall x. BatchReadException -> Rep BatchReadException x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchReadException x -> BatchReadException
$cfrom :: forall x. BatchReadException -> Rep BatchReadException x
Prelude.Generic)

-- |
-- Create a value of 'BatchReadException' 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:
--
-- 'message', 'batchReadException_message' - An exception message that is associated with the failure.
--
-- 'type'', 'batchReadException_type' - A type of exception, such as @InvalidArnException@.
newBatchReadException ::
  BatchReadException
newBatchReadException :: BatchReadException
newBatchReadException =
  BatchReadException'
    { $sel:message:BatchReadException' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:type':BatchReadException' :: Maybe BatchReadExceptionType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | An exception message that is associated with the failure.
batchReadException_message :: Lens.Lens' BatchReadException (Prelude.Maybe Prelude.Text)
batchReadException_message :: Lens' BatchReadException (Maybe Text)
batchReadException_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchReadException' {Maybe Text
message :: Maybe Text
$sel:message:BatchReadException' :: BatchReadException -> Maybe Text
message} -> Maybe Text
message) (\s :: BatchReadException
s@BatchReadException' {} Maybe Text
a -> BatchReadException
s {$sel:message:BatchReadException' :: Maybe Text
message = Maybe Text
a} :: BatchReadException)

-- | A type of exception, such as @InvalidArnException@.
batchReadException_type :: Lens.Lens' BatchReadException (Prelude.Maybe BatchReadExceptionType)
batchReadException_type :: Lens' BatchReadException (Maybe BatchReadExceptionType)
batchReadException_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchReadException' {Maybe BatchReadExceptionType
type' :: Maybe BatchReadExceptionType
$sel:type':BatchReadException' :: BatchReadException -> Maybe BatchReadExceptionType
type'} -> Maybe BatchReadExceptionType
type') (\s :: BatchReadException
s@BatchReadException' {} Maybe BatchReadExceptionType
a -> BatchReadException
s {$sel:type':BatchReadException' :: Maybe BatchReadExceptionType
type' = Maybe BatchReadExceptionType
a} :: BatchReadException)

instance Data.FromJSON BatchReadException where
  parseJSON :: Value -> Parser BatchReadException
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BatchReadException"
      ( \Object
x ->
          Maybe Text -> Maybe BatchReadExceptionType -> BatchReadException
BatchReadException'
            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
"Message")
            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
"Type")
      )

instance Prelude.Hashable BatchReadException where
  hashWithSalt :: Int -> BatchReadException -> Int
hashWithSalt Int
_salt BatchReadException' {Maybe Text
Maybe BatchReadExceptionType
type' :: Maybe BatchReadExceptionType
message :: Maybe Text
$sel:type':BatchReadException' :: BatchReadException -> Maybe BatchReadExceptionType
$sel:message:BatchReadException' :: BatchReadException -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BatchReadExceptionType
type'

instance Prelude.NFData BatchReadException where
  rnf :: BatchReadException -> ()
rnf BatchReadException' {Maybe Text
Maybe BatchReadExceptionType
type' :: Maybe BatchReadExceptionType
message :: Maybe Text
$sel:type':BatchReadException' :: BatchReadException -> Maybe BatchReadExceptionType
$sel:message:BatchReadException' :: BatchReadException -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BatchReadExceptionType
type'