{-# 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.Glue.Types.ColumnError
-- 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.Glue.Types.ColumnError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.ErrorDetail
import qualified Amazonka.Prelude as Prelude

-- | Encapsulates a column name that failed and the reason for failure.
--
-- /See:/ 'newColumnError' smart constructor.
data ColumnError = ColumnError'
  { -- | The name of the column that failed.
    ColumnError -> Maybe Text
columnName :: Prelude.Maybe Prelude.Text,
    -- | An error message with the reason for the failure of an operation.
    ColumnError -> Maybe ErrorDetail
error :: Prelude.Maybe ErrorDetail
  }
  deriving (ColumnError -> ColumnError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnError -> ColumnError -> Bool
$c/= :: ColumnError -> ColumnError -> Bool
== :: ColumnError -> ColumnError -> Bool
$c== :: ColumnError -> ColumnError -> Bool
Prelude.Eq, ReadPrec [ColumnError]
ReadPrec ColumnError
Int -> ReadS ColumnError
ReadS [ColumnError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnError]
$creadListPrec :: ReadPrec [ColumnError]
readPrec :: ReadPrec ColumnError
$creadPrec :: ReadPrec ColumnError
readList :: ReadS [ColumnError]
$creadList :: ReadS [ColumnError]
readsPrec :: Int -> ReadS ColumnError
$creadsPrec :: Int -> ReadS ColumnError
Prelude.Read, Int -> ColumnError -> ShowS
[ColumnError] -> ShowS
ColumnError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnError] -> ShowS
$cshowList :: [ColumnError] -> ShowS
show :: ColumnError -> String
$cshow :: ColumnError -> String
showsPrec :: Int -> ColumnError -> ShowS
$cshowsPrec :: Int -> ColumnError -> ShowS
Prelude.Show, forall x. Rep ColumnError x -> ColumnError
forall x. ColumnError -> Rep ColumnError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnError x -> ColumnError
$cfrom :: forall x. ColumnError -> Rep ColumnError x
Prelude.Generic)

-- |
-- Create a value of 'ColumnError' 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:
--
-- 'columnName', 'columnError_columnName' - The name of the column that failed.
--
-- 'error', 'columnError_error' - An error message with the reason for the failure of an operation.
newColumnError ::
  ColumnError
newColumnError :: ColumnError
newColumnError =
  ColumnError'
    { $sel:columnName:ColumnError' :: Maybe Text
columnName = forall a. Maybe a
Prelude.Nothing,
      $sel:error:ColumnError' :: Maybe ErrorDetail
error = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the column that failed.
columnError_columnName :: Lens.Lens' ColumnError (Prelude.Maybe Prelude.Text)
columnError_columnName :: Lens' ColumnError (Maybe Text)
columnError_columnName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnError' {Maybe Text
columnName :: Maybe Text
$sel:columnName:ColumnError' :: ColumnError -> Maybe Text
columnName} -> Maybe Text
columnName) (\s :: ColumnError
s@ColumnError' {} Maybe Text
a -> ColumnError
s {$sel:columnName:ColumnError' :: Maybe Text
columnName = Maybe Text
a} :: ColumnError)

-- | An error message with the reason for the failure of an operation.
columnError_error :: Lens.Lens' ColumnError (Prelude.Maybe ErrorDetail)
columnError_error :: Lens' ColumnError (Maybe ErrorDetail)
columnError_error = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnError' {Maybe ErrorDetail
error :: Maybe ErrorDetail
$sel:error:ColumnError' :: ColumnError -> Maybe ErrorDetail
error} -> Maybe ErrorDetail
error) (\s :: ColumnError
s@ColumnError' {} Maybe ErrorDetail
a -> ColumnError
s {$sel:error:ColumnError' :: Maybe ErrorDetail
error = Maybe ErrorDetail
a} :: ColumnError)

instance Data.FromJSON ColumnError where
  parseJSON :: Value -> Parser ColumnError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColumnError"
      ( \Object
x ->
          Maybe Text -> Maybe ErrorDetail -> ColumnError
ColumnError'
            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
"ColumnName")
            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
"Error")
      )

instance Prelude.Hashable ColumnError where
  hashWithSalt :: Int -> ColumnError -> Int
hashWithSalt Int
_salt ColumnError' {Maybe Text
Maybe ErrorDetail
error :: Maybe ErrorDetail
columnName :: Maybe Text
$sel:error:ColumnError' :: ColumnError -> Maybe ErrorDetail
$sel:columnName:ColumnError' :: ColumnError -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
columnName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ErrorDetail
error

instance Prelude.NFData ColumnError where
  rnf :: ColumnError -> ()
rnf ColumnError' {Maybe Text
Maybe ErrorDetail
error :: Maybe ErrorDetail
columnName :: Maybe Text
$sel:error:ColumnError' :: ColumnError -> Maybe ErrorDetail
$sel:columnName:ColumnError' :: ColumnError -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
columnName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ErrorDetail
error