{-# 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.OpenSearch.Types.ErrorDetails
-- 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.OpenSearch.Types.ErrorDetails where

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

-- | /See:/ 'newErrorDetails' smart constructor.
data ErrorDetails = ErrorDetails'
  { ErrorDetails -> Maybe Text
errorType :: Prelude.Maybe Prelude.Text,
    ErrorDetails -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (ErrorDetails -> ErrorDetails -> Bool
(ErrorDetails -> ErrorDetails -> Bool)
-> (ErrorDetails -> ErrorDetails -> Bool) -> Eq ErrorDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorDetails -> ErrorDetails -> Bool
$c/= :: ErrorDetails -> ErrorDetails -> Bool
== :: ErrorDetails -> ErrorDetails -> Bool
$c== :: ErrorDetails -> ErrorDetails -> Bool
Prelude.Eq, ReadPrec [ErrorDetails]
ReadPrec ErrorDetails
Int -> ReadS ErrorDetails
ReadS [ErrorDetails]
(Int -> ReadS ErrorDetails)
-> ReadS [ErrorDetails]
-> ReadPrec ErrorDetails
-> ReadPrec [ErrorDetails]
-> Read ErrorDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorDetails]
$creadListPrec :: ReadPrec [ErrorDetails]
readPrec :: ReadPrec ErrorDetails
$creadPrec :: ReadPrec ErrorDetails
readList :: ReadS [ErrorDetails]
$creadList :: ReadS [ErrorDetails]
readsPrec :: Int -> ReadS ErrorDetails
$creadsPrec :: Int -> ReadS ErrorDetails
Prelude.Read, Int -> ErrorDetails -> ShowS
[ErrorDetails] -> ShowS
ErrorDetails -> String
(Int -> ErrorDetails -> ShowS)
-> (ErrorDetails -> String)
-> ([ErrorDetails] -> ShowS)
-> Show ErrorDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorDetails] -> ShowS
$cshowList :: [ErrorDetails] -> ShowS
show :: ErrorDetails -> String
$cshow :: ErrorDetails -> String
showsPrec :: Int -> ErrorDetails -> ShowS
$cshowsPrec :: Int -> ErrorDetails -> ShowS
Prelude.Show, (forall x. ErrorDetails -> Rep ErrorDetails x)
-> (forall x. Rep ErrorDetails x -> ErrorDetails)
-> Generic ErrorDetails
forall x. Rep ErrorDetails x -> ErrorDetails
forall x. ErrorDetails -> Rep ErrorDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorDetails x -> ErrorDetails
$cfrom :: forall x. ErrorDetails -> Rep ErrorDetails x
Prelude.Generic)

-- |
-- Create a value of 'ErrorDetails' 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:
--
-- 'errorType', 'errorDetails_errorType' - Undocumented member.
--
-- 'errorMessage', 'errorDetails_errorMessage' - Undocumented member.
newErrorDetails ::
  ErrorDetails
newErrorDetails :: ErrorDetails
newErrorDetails =
  ErrorDetails' :: Maybe Text -> Maybe Text -> ErrorDetails
ErrorDetails'
    { $sel:errorType:ErrorDetails' :: Maybe Text
errorType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:ErrorDetails' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
errorDetails_errorType :: Lens.Lens' ErrorDetails (Prelude.Maybe Prelude.Text)
errorDetails_errorType :: (Maybe Text -> f (Maybe Text)) -> ErrorDetails -> f ErrorDetails
errorDetails_errorType = (ErrorDetails -> Maybe Text)
-> (ErrorDetails -> Maybe Text -> ErrorDetails)
-> Lens ErrorDetails ErrorDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorDetails' {Maybe Text
errorType :: Maybe Text
$sel:errorType:ErrorDetails' :: ErrorDetails -> Maybe Text
errorType} -> Maybe Text
errorType) (\s :: ErrorDetails
s@ErrorDetails' {} Maybe Text
a -> ErrorDetails
s {$sel:errorType:ErrorDetails' :: Maybe Text
errorType = Maybe Text
a} :: ErrorDetails)

-- | Undocumented member.
errorDetails_errorMessage :: Lens.Lens' ErrorDetails (Prelude.Maybe Prelude.Text)
errorDetails_errorMessage :: (Maybe Text -> f (Maybe Text)) -> ErrorDetails -> f ErrorDetails
errorDetails_errorMessage = (ErrorDetails -> Maybe Text)
-> (ErrorDetails -> Maybe Text -> ErrorDetails)
-> Lens ErrorDetails ErrorDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorDetails' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:ErrorDetails' :: ErrorDetails -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: ErrorDetails
s@ErrorDetails' {} Maybe Text
a -> ErrorDetails
s {$sel:errorMessage:ErrorDetails' :: Maybe Text
errorMessage = Maybe Text
a} :: ErrorDetails)

instance Core.FromJSON ErrorDetails where
  parseJSON :: Value -> Parser ErrorDetails
parseJSON =
    String
-> (Object -> Parser ErrorDetails) -> Value -> Parser ErrorDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ErrorDetails"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ErrorDetails
ErrorDetails'
            (Maybe Text -> Maybe Text -> ErrorDetails)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ErrorDetails)
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
"ErrorType")
            Parser (Maybe Text -> ErrorDetails)
-> Parser (Maybe Text) -> Parser ErrorDetails
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 ErrorDetails

instance Prelude.NFData ErrorDetails