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

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

-- | Details about the error.
--
-- /See:/ 'newErrorDetail' smart constructor.
data ErrorDetail = ErrorDetail'
  { -- | A detailed error code.
    ErrorDetail -> Maybe Text
detailedErrorCode :: Prelude.Maybe Prelude.Text,
    -- | A detailed error message.
    ErrorDetail -> Maybe Text
detailedErrorMessage :: 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:
--
-- 'detailedErrorCode', 'errorDetail_detailedErrorCode' - A detailed error code.
--
-- 'detailedErrorMessage', 'errorDetail_detailedErrorMessage' - A detailed error message.
newErrorDetail ::
  ErrorDetail
newErrorDetail :: ErrorDetail
newErrorDetail =
  ErrorDetail' :: Maybe Text -> Maybe Text -> ErrorDetail
ErrorDetail'
    { $sel:detailedErrorCode:ErrorDetail' :: Maybe Text
detailedErrorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:detailedErrorMessage:ErrorDetail' :: Maybe Text
detailedErrorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A detailed error code.
errorDetail_detailedErrorCode :: Lens.Lens' ErrorDetail (Prelude.Maybe Prelude.Text)
errorDetail_detailedErrorCode :: (Maybe Text -> f (Maybe Text)) -> ErrorDetail -> f ErrorDetail
errorDetail_detailedErrorCode = (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
detailedErrorCode :: Maybe Text
$sel:detailedErrorCode:ErrorDetail' :: ErrorDetail -> Maybe Text
detailedErrorCode} -> Maybe Text
detailedErrorCode) (\s :: ErrorDetail
s@ErrorDetail' {} Maybe Text
a -> ErrorDetail
s {$sel:detailedErrorCode:ErrorDetail' :: Maybe Text
detailedErrorCode = Maybe Text
a} :: ErrorDetail)

-- | A detailed error message.
errorDetail_detailedErrorMessage :: Lens.Lens' ErrorDetail (Prelude.Maybe Prelude.Text)
errorDetail_detailedErrorMessage :: (Maybe Text -> f (Maybe Text)) -> ErrorDetail -> f ErrorDetail
errorDetail_detailedErrorMessage = (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
detailedErrorMessage :: Maybe Text
$sel:detailedErrorMessage:ErrorDetail' :: ErrorDetail -> Maybe Text
detailedErrorMessage} -> Maybe Text
detailedErrorMessage) (\s :: ErrorDetail
s@ErrorDetail' {} Maybe Text
a -> ErrorDetail
s {$sel:detailedErrorMessage:ErrorDetail' :: Maybe Text
detailedErrorMessage = 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
"DetailedErrorCode")
            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
"DetailedErrorMessage")
      )

instance Prelude.Hashable ErrorDetail

instance Prelude.NFData ErrorDetail