{-# 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.AppStream.Types.StackError
-- 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.AppStream.Types.StackError where

import Amazonka.AppStream.Types.StackErrorCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'StackError' 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', 'stackError_errorCode' - The error code.
--
-- 'errorMessage', 'stackError_errorMessage' - The error message.
newStackError ::
  StackError
newStackError :: StackError
newStackError =
  StackError' :: Maybe StackErrorCode -> Maybe Text -> StackError
StackError'
    { $sel:errorCode:StackError' :: Maybe StackErrorCode
errorCode = Maybe StackErrorCode
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:StackError' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The error code.
stackError_errorCode :: Lens.Lens' StackError (Prelude.Maybe StackErrorCode)
stackError_errorCode :: (Maybe StackErrorCode -> f (Maybe StackErrorCode))
-> StackError -> f StackError
stackError_errorCode = (StackError -> Maybe StackErrorCode)
-> (StackError -> Maybe StackErrorCode -> StackError)
-> Lens
     StackError StackError (Maybe StackErrorCode) (Maybe StackErrorCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StackError' {Maybe StackErrorCode
errorCode :: Maybe StackErrorCode
$sel:errorCode:StackError' :: StackError -> Maybe StackErrorCode
errorCode} -> Maybe StackErrorCode
errorCode) (\s :: StackError
s@StackError' {} Maybe StackErrorCode
a -> StackError
s {$sel:errorCode:StackError' :: Maybe StackErrorCode
errorCode = Maybe StackErrorCode
a} :: StackError)

-- | The error message.
stackError_errorMessage :: Lens.Lens' StackError (Prelude.Maybe Prelude.Text)
stackError_errorMessage :: (Maybe Text -> f (Maybe Text)) -> StackError -> f StackError
stackError_errorMessage = (StackError -> Maybe Text)
-> (StackError -> Maybe Text -> StackError)
-> Lens StackError StackError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StackError' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:StackError' :: StackError -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: StackError
s@StackError' {} Maybe Text
a -> StackError
s {$sel:errorMessage:StackError' :: Maybe Text
errorMessage = Maybe Text
a} :: StackError)

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

instance Prelude.NFData StackError