{-# 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.XRay.Types.RootCauseException
-- 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.XRay.Types.RootCauseException where

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

-- | The exception associated with a root cause.
--
-- /See:/ 'newRootCauseException' smart constructor.
data RootCauseException = RootCauseException'
  { -- | The name of the exception.
    RootCauseException -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The message of the exception.
    RootCauseException -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (RootCauseException -> RootCauseException -> Bool
(RootCauseException -> RootCauseException -> Bool)
-> (RootCauseException -> RootCauseException -> Bool)
-> Eq RootCauseException
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RootCauseException -> RootCauseException -> Bool
$c/= :: RootCauseException -> RootCauseException -> Bool
== :: RootCauseException -> RootCauseException -> Bool
$c== :: RootCauseException -> RootCauseException -> Bool
Prelude.Eq, ReadPrec [RootCauseException]
ReadPrec RootCauseException
Int -> ReadS RootCauseException
ReadS [RootCauseException]
(Int -> ReadS RootCauseException)
-> ReadS [RootCauseException]
-> ReadPrec RootCauseException
-> ReadPrec [RootCauseException]
-> Read RootCauseException
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RootCauseException]
$creadListPrec :: ReadPrec [RootCauseException]
readPrec :: ReadPrec RootCauseException
$creadPrec :: ReadPrec RootCauseException
readList :: ReadS [RootCauseException]
$creadList :: ReadS [RootCauseException]
readsPrec :: Int -> ReadS RootCauseException
$creadsPrec :: Int -> ReadS RootCauseException
Prelude.Read, Int -> RootCauseException -> ShowS
[RootCauseException] -> ShowS
RootCauseException -> String
(Int -> RootCauseException -> ShowS)
-> (RootCauseException -> String)
-> ([RootCauseException] -> ShowS)
-> Show RootCauseException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RootCauseException] -> ShowS
$cshowList :: [RootCauseException] -> ShowS
show :: RootCauseException -> String
$cshow :: RootCauseException -> String
showsPrec :: Int -> RootCauseException -> ShowS
$cshowsPrec :: Int -> RootCauseException -> ShowS
Prelude.Show, (forall x. RootCauseException -> Rep RootCauseException x)
-> (forall x. Rep RootCauseException x -> RootCauseException)
-> Generic RootCauseException
forall x. Rep RootCauseException x -> RootCauseException
forall x. RootCauseException -> Rep RootCauseException x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RootCauseException x -> RootCauseException
$cfrom :: forall x. RootCauseException -> Rep RootCauseException x
Prelude.Generic)

-- |
-- Create a value of 'RootCauseException' 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:
--
-- 'name', 'rootCauseException_name' - The name of the exception.
--
-- 'message', 'rootCauseException_message' - The message of the exception.
newRootCauseException ::
  RootCauseException
newRootCauseException :: RootCauseException
newRootCauseException =
  RootCauseException' :: Maybe Text -> Maybe Text -> RootCauseException
RootCauseException'
    { $sel:name:RootCauseException' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:RootCauseException' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the exception.
rootCauseException_name :: Lens.Lens' RootCauseException (Prelude.Maybe Prelude.Text)
rootCauseException_name :: (Maybe Text -> f (Maybe Text))
-> RootCauseException -> f RootCauseException
rootCauseException_name = (RootCauseException -> Maybe Text)
-> (RootCauseException -> Maybe Text -> RootCauseException)
-> Lens
     RootCauseException RootCauseException (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RootCauseException' {Maybe Text
name :: Maybe Text
$sel:name:RootCauseException' :: RootCauseException -> Maybe Text
name} -> Maybe Text
name) (\s :: RootCauseException
s@RootCauseException' {} Maybe Text
a -> RootCauseException
s {$sel:name:RootCauseException' :: Maybe Text
name = Maybe Text
a} :: RootCauseException)

-- | The message of the exception.
rootCauseException_message :: Lens.Lens' RootCauseException (Prelude.Maybe Prelude.Text)
rootCauseException_message :: (Maybe Text -> f (Maybe Text))
-> RootCauseException -> f RootCauseException
rootCauseException_message = (RootCauseException -> Maybe Text)
-> (RootCauseException -> Maybe Text -> RootCauseException)
-> Lens
     RootCauseException RootCauseException (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RootCauseException' {Maybe Text
message :: Maybe Text
$sel:message:RootCauseException' :: RootCauseException -> Maybe Text
message} -> Maybe Text
message) (\s :: RootCauseException
s@RootCauseException' {} Maybe Text
a -> RootCauseException
s {$sel:message:RootCauseException' :: Maybe Text
message = Maybe Text
a} :: RootCauseException)

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

instance Prelude.Hashable RootCauseException

instance Prelude.NFData RootCauseException