{-# 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.LakeFormation.Types.ErrorDetail
-- 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.LakeFormation.Types.ErrorDetail where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains details about an error.
--
-- /See:/ 'newErrorDetail' smart constructor.
data ErrorDetail = ErrorDetail'
  { -- | The code associated with this error.
    ErrorDetail -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | A message describing the error.
    ErrorDetail -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (ErrorDetail -> ErrorDetail -> Bool
(ErrorDetail -> ErrorDetail -> Bool)
-> (ErrorDetail -> ErrorDetail -> Bool) -> Eq ErrorDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorDetail -> ErrorDetail -> Bool
$c/= :: ErrorDetail -> ErrorDetail -> Bool
== :: ErrorDetail -> ErrorDetail -> Bool
$c== :: ErrorDetail -> ErrorDetail -> Bool
Prelude.Eq, ReadPrec [ErrorDetail]
ReadPrec ErrorDetail
Int -> ReadS ErrorDetail
ReadS [ErrorDetail]
(Int -> ReadS ErrorDetail)
-> ReadS [ErrorDetail]
-> ReadPrec ErrorDetail
-> ReadPrec [ErrorDetail]
-> Read ErrorDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorDetail]
$creadListPrec :: ReadPrec [ErrorDetail]
readPrec :: ReadPrec ErrorDetail
$creadPrec :: ReadPrec ErrorDetail
readList :: ReadS [ErrorDetail]
$creadList :: ReadS [ErrorDetail]
readsPrec :: Int -> ReadS ErrorDetail
$creadsPrec :: Int -> ReadS ErrorDetail
Prelude.Read, Int -> ErrorDetail -> ShowS
[ErrorDetail] -> ShowS
ErrorDetail -> String
(Int -> ErrorDetail -> ShowS)
-> (ErrorDetail -> String)
-> ([ErrorDetail] -> ShowS)
-> Show ErrorDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorDetail] -> ShowS
$cshowList :: [ErrorDetail] -> ShowS
show :: ErrorDetail -> String
$cshow :: ErrorDetail -> String
showsPrec :: Int -> ErrorDetail -> ShowS
$cshowsPrec :: Int -> ErrorDetail -> ShowS
Prelude.Show, (forall x. ErrorDetail -> Rep ErrorDetail x)
-> (forall x. Rep ErrorDetail x -> ErrorDetail)
-> Generic ErrorDetail
forall x. Rep ErrorDetail x -> ErrorDetail
forall x. ErrorDetail -> Rep ErrorDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorDetail x -> ErrorDetail
$cfrom :: forall x. ErrorDetail -> Rep ErrorDetail x
Prelude.Generic)

-- |
-- Create a value of 'ErrorDetail' 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', 'errorDetail_errorCode' - The code associated with this error.
--
-- 'errorMessage', 'errorDetail_errorMessage' - A message describing the error.
newErrorDetail ::
  ErrorDetail
newErrorDetail :: ErrorDetail
newErrorDetail =
  ErrorDetail' :: Maybe Text -> Maybe Text -> ErrorDetail
ErrorDetail'
    { $sel:errorCode:ErrorDetail' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:ErrorDetail' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The code associated with this error.
errorDetail_errorCode :: Lens.Lens' ErrorDetail (Prelude.Maybe Prelude.Text)
errorDetail_errorCode :: (Maybe Text -> f (Maybe Text)) -> ErrorDetail -> f ErrorDetail
errorDetail_errorCode = (ErrorDetail -> Maybe Text)
-> (ErrorDetail -> Maybe Text -> ErrorDetail)
-> Lens ErrorDetail ErrorDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorDetail' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:ErrorDetail' :: ErrorDetail -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: ErrorDetail
s@ErrorDetail' {} Maybe Text
a -> ErrorDetail
s {$sel:errorCode:ErrorDetail' :: Maybe Text
errorCode = Maybe Text
a} :: ErrorDetail)

-- | A message describing the error.
errorDetail_errorMessage :: Lens.Lens' ErrorDetail (Prelude.Maybe Prelude.Text)
errorDetail_errorMessage :: (Maybe Text -> f (Maybe Text)) -> ErrorDetail -> f ErrorDetail
errorDetail_errorMessage = (ErrorDetail -> Maybe Text)
-> (ErrorDetail -> Maybe Text -> ErrorDetail)
-> Lens ErrorDetail ErrorDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorDetail' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:ErrorDetail' :: ErrorDetail -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: ErrorDetail
s@ErrorDetail' {} Maybe Text
a -> ErrorDetail
s {$sel:errorMessage:ErrorDetail' :: Maybe Text
errorMessage = Maybe Text
a} :: ErrorDetail)

instance Core.FromJSON ErrorDetail where
  parseJSON :: Value -> Parser ErrorDetail
parseJSON =
    String
-> (Object -> Parser ErrorDetail) -> Value -> Parser ErrorDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ErrorDetail"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ErrorDetail
ErrorDetail'
            (Maybe Text -> Maybe Text -> ErrorDetail)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ErrorDetail)
forall (f :: * -> *) a b. Functor 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
"ErrorCode")
            Parser (Maybe Text -> ErrorDetail)
-> Parser (Maybe Text) -> Parser ErrorDetail
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 ErrorDetail

instance Prelude.NFData ErrorDetail