{-# 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.Comprehend.Types.BatchItemError
-- 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.Comprehend.Types.BatchItemError where

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

-- | Describes an error that occurred while processing a document in a batch.
-- The operation returns on @BatchItemError@ object for each document that
-- contained an error.
--
-- /See:/ 'newBatchItemError' smart constructor.
data BatchItemError = BatchItemError'
  { -- | The numeric error code of the error.
    BatchItemError -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | A text description of the error.
    BatchItemError -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The zero-based index of the document in the input list.
    BatchItemError -> Maybe Int
index :: Prelude.Maybe Prelude.Int
  }
  deriving (BatchItemError -> BatchItemError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchItemError -> BatchItemError -> Bool
$c/= :: BatchItemError -> BatchItemError -> Bool
== :: BatchItemError -> BatchItemError -> Bool
$c== :: BatchItemError -> BatchItemError -> Bool
Prelude.Eq, ReadPrec [BatchItemError]
ReadPrec BatchItemError
Int -> ReadS BatchItemError
ReadS [BatchItemError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchItemError]
$creadListPrec :: ReadPrec [BatchItemError]
readPrec :: ReadPrec BatchItemError
$creadPrec :: ReadPrec BatchItemError
readList :: ReadS [BatchItemError]
$creadList :: ReadS [BatchItemError]
readsPrec :: Int -> ReadS BatchItemError
$creadsPrec :: Int -> ReadS BatchItemError
Prelude.Read, Int -> BatchItemError -> ShowS
[BatchItemError] -> ShowS
BatchItemError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchItemError] -> ShowS
$cshowList :: [BatchItemError] -> ShowS
show :: BatchItemError -> String
$cshow :: BatchItemError -> String
showsPrec :: Int -> BatchItemError -> ShowS
$cshowsPrec :: Int -> BatchItemError -> ShowS
Prelude.Show, forall x. Rep BatchItemError x -> BatchItemError
forall x. BatchItemError -> Rep BatchItemError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchItemError x -> BatchItemError
$cfrom :: forall x. BatchItemError -> Rep BatchItemError x
Prelude.Generic)

-- |
-- Create a value of 'BatchItemError' 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:
--
-- 'errorCode', 'batchItemError_errorCode' - The numeric error code of the error.
--
-- 'errorMessage', 'batchItemError_errorMessage' - A text description of the error.
--
-- 'index', 'batchItemError_index' - The zero-based index of the document in the input list.
newBatchItemError ::
  BatchItemError
newBatchItemError :: BatchItemError
newBatchItemError =
  BatchItemError'
    { $sel:errorCode:BatchItemError' :: Maybe Text
errorCode = forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:BatchItemError' :: Maybe Text
errorMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:index:BatchItemError' :: Maybe Int
index = forall a. Maybe a
Prelude.Nothing
    }

-- | The numeric error code of the error.
batchItemError_errorCode :: Lens.Lens' BatchItemError (Prelude.Maybe Prelude.Text)
batchItemError_errorCode :: Lens' BatchItemError (Maybe Text)
batchItemError_errorCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchItemError' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:BatchItemError' :: BatchItemError -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: BatchItemError
s@BatchItemError' {} Maybe Text
a -> BatchItemError
s {$sel:errorCode:BatchItemError' :: Maybe Text
errorCode = Maybe Text
a} :: BatchItemError)

-- | A text description of the error.
batchItemError_errorMessage :: Lens.Lens' BatchItemError (Prelude.Maybe Prelude.Text)
batchItemError_errorMessage :: Lens' BatchItemError (Maybe Text)
batchItemError_errorMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchItemError' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:BatchItemError' :: BatchItemError -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: BatchItemError
s@BatchItemError' {} Maybe Text
a -> BatchItemError
s {$sel:errorMessage:BatchItemError' :: Maybe Text
errorMessage = Maybe Text
a} :: BatchItemError)

-- | The zero-based index of the document in the input list.
batchItemError_index :: Lens.Lens' BatchItemError (Prelude.Maybe Prelude.Int)
batchItemError_index :: Lens' BatchItemError (Maybe Int)
batchItemError_index = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchItemError' {Maybe Int
index :: Maybe Int
$sel:index:BatchItemError' :: BatchItemError -> Maybe Int
index} -> Maybe Int
index) (\s :: BatchItemError
s@BatchItemError' {} Maybe Int
a -> BatchItemError
s {$sel:index:BatchItemError' :: Maybe Int
index = Maybe Int
a} :: BatchItemError)

instance Data.FromJSON BatchItemError where
  parseJSON :: Value -> Parser BatchItemError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BatchItemError"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Int -> BatchItemError
BatchItemError'
            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
"ErrorCode")
            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
"ErrorMessage")
            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
"Index")
      )

instance Prelude.Hashable BatchItemError where
  hashWithSalt :: Int -> BatchItemError -> Int
hashWithSalt Int
_salt BatchItemError' {Maybe Int
Maybe Text
index :: Maybe Int
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:index:BatchItemError' :: BatchItemError -> Maybe Int
$sel:errorMessage:BatchItemError' :: BatchItemError -> Maybe Text
$sel:errorCode:BatchItemError' :: BatchItemError -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
index

instance Prelude.NFData BatchItemError where
  rnf :: BatchItemError -> ()
rnf BatchItemError' {Maybe Int
Maybe Text
index :: Maybe Int
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:index:BatchItemError' :: BatchItemError -> Maybe Int
$sel:errorMessage:BatchItemError' :: BatchItemError -> Maybe Text
$sel:errorCode:BatchItemError' :: BatchItemError -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
index