{-# 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.AccessAnalyzer.Types.JobError
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AccessAnalyzer.Types.JobError where

import Amazonka.AccessAnalyzer.Types.JobErrorCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Contains the details about the policy generation error.
--
-- /See:/ 'newJobError' smart constructor.
data JobError = JobError'
  { -- | The job error code.
    JobError -> JobErrorCode
code :: JobErrorCode,
    -- | Specific information about the error. For example, which service quota
    -- was exceeded or which resource was not found.
    JobError -> Text
message :: Prelude.Text
  }
  deriving (JobError -> JobError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobError -> JobError -> Bool
$c/= :: JobError -> JobError -> Bool
== :: JobError -> JobError -> Bool
$c== :: JobError -> JobError -> Bool
Prelude.Eq, ReadPrec [JobError]
ReadPrec JobError
Int -> ReadS JobError
ReadS [JobError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobError]
$creadListPrec :: ReadPrec [JobError]
readPrec :: ReadPrec JobError
$creadPrec :: ReadPrec JobError
readList :: ReadS [JobError]
$creadList :: ReadS [JobError]
readsPrec :: Int -> ReadS JobError
$creadsPrec :: Int -> ReadS JobError
Prelude.Read, Int -> JobError -> ShowS
[JobError] -> ShowS
JobError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobError] -> ShowS
$cshowList :: [JobError] -> ShowS
show :: JobError -> String
$cshow :: JobError -> String
showsPrec :: Int -> JobError -> ShowS
$cshowsPrec :: Int -> JobError -> ShowS
Prelude.Show, forall x. Rep JobError x -> JobError
forall x. JobError -> Rep JobError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobError x -> JobError
$cfrom :: forall x. JobError -> Rep JobError x
Prelude.Generic)

-- |
-- Create a value of 'JobError' 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:
--
-- 'code', 'jobError_code' - The job error code.
--
-- 'message', 'jobError_message' - Specific information about the error. For example, which service quota
-- was exceeded or which resource was not found.
newJobError ::
  -- | 'code'
  JobErrorCode ->
  -- | 'message'
  Prelude.Text ->
  JobError
newJobError :: JobErrorCode -> Text -> JobError
newJobError JobErrorCode
pCode_ Text
pMessage_ =
  JobError' {$sel:code:JobError' :: JobErrorCode
code = JobErrorCode
pCode_, $sel:message:JobError' :: Text
message = Text
pMessage_}

-- | The job error code.
jobError_code :: Lens.Lens' JobError JobErrorCode
jobError_code :: Lens' JobError JobErrorCode
jobError_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobError' {JobErrorCode
code :: JobErrorCode
$sel:code:JobError' :: JobError -> JobErrorCode
code} -> JobErrorCode
code) (\s :: JobError
s@JobError' {} JobErrorCode
a -> JobError
s {$sel:code:JobError' :: JobErrorCode
code = JobErrorCode
a} :: JobError)

-- | Specific information about the error. For example, which service quota
-- was exceeded or which resource was not found.
jobError_message :: Lens.Lens' JobError Prelude.Text
jobError_message :: Lens' JobError Text
jobError_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobError' {Text
message :: Text
$sel:message:JobError' :: JobError -> Text
message} -> Text
message) (\s :: JobError
s@JobError' {} Text
a -> JobError
s {$sel:message:JobError' :: Text
message = Text
a} :: JobError)

instance Data.FromJSON JobError where
  parseJSON :: Value -> Parser JobError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JobError"
      ( \Object
x ->
          JobErrorCode -> Text -> JobError
JobError'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"code")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"message")
      )

instance Prelude.Hashable JobError where
  hashWithSalt :: Int -> JobError -> Int
hashWithSalt Int
_salt JobError' {Text
JobErrorCode
message :: Text
code :: JobErrorCode
$sel:message:JobError' :: JobError -> Text
$sel:code:JobError' :: JobError -> JobErrorCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` JobErrorCode
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
message

instance Prelude.NFData JobError where
  rnf :: JobError -> ()
rnf JobError' {Text
JobErrorCode
message :: Text
code :: JobErrorCode
$sel:message:JobError' :: JobError -> Text
$sel:code:JobError' :: JobError -> JobErrorCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf JobErrorCode
code seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
message