{-# 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.EMR.Types.FailureDetails
-- 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.EMR.Types.FailureDetails where

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

-- | The details of the step failure. The service attempts to detect the root
-- cause for many common failures.
--
-- /See:/ 'newFailureDetails' smart constructor.
data FailureDetails = FailureDetails'
  { -- | The path to the log file where the step failure root cause was
    -- originally recorded.
    FailureDetails -> Maybe Text
logFile :: Prelude.Maybe Prelude.Text,
    -- | The descriptive message including the error the Amazon EMR service has
    -- identified as the cause of step failure. This is text from an error log
    -- that describes the root cause of the failure.
    FailureDetails -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The reason for the step failure. In the case where the service cannot
    -- successfully determine the root cause of the failure, it returns
    -- \"Unknown Error\" as a reason.
    FailureDetails -> Maybe Text
reason :: Prelude.Maybe Prelude.Text
  }
  deriving (FailureDetails -> FailureDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailureDetails -> FailureDetails -> Bool
$c/= :: FailureDetails -> FailureDetails -> Bool
== :: FailureDetails -> FailureDetails -> Bool
$c== :: FailureDetails -> FailureDetails -> Bool
Prelude.Eq, ReadPrec [FailureDetails]
ReadPrec FailureDetails
Int -> ReadS FailureDetails
ReadS [FailureDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailureDetails]
$creadListPrec :: ReadPrec [FailureDetails]
readPrec :: ReadPrec FailureDetails
$creadPrec :: ReadPrec FailureDetails
readList :: ReadS [FailureDetails]
$creadList :: ReadS [FailureDetails]
readsPrec :: Int -> ReadS FailureDetails
$creadsPrec :: Int -> ReadS FailureDetails
Prelude.Read, Int -> FailureDetails -> ShowS
[FailureDetails] -> ShowS
FailureDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailureDetails] -> ShowS
$cshowList :: [FailureDetails] -> ShowS
show :: FailureDetails -> String
$cshow :: FailureDetails -> String
showsPrec :: Int -> FailureDetails -> ShowS
$cshowsPrec :: Int -> FailureDetails -> ShowS
Prelude.Show, forall x. Rep FailureDetails x -> FailureDetails
forall x. FailureDetails -> Rep FailureDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailureDetails x -> FailureDetails
$cfrom :: forall x. FailureDetails -> Rep FailureDetails x
Prelude.Generic)

-- |
-- Create a value of 'FailureDetails' 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:
--
-- 'logFile', 'failureDetails_logFile' - The path to the log file where the step failure root cause was
-- originally recorded.
--
-- 'message', 'failureDetails_message' - The descriptive message including the error the Amazon EMR service has
-- identified as the cause of step failure. This is text from an error log
-- that describes the root cause of the failure.
--
-- 'reason', 'failureDetails_reason' - The reason for the step failure. In the case where the service cannot
-- successfully determine the root cause of the failure, it returns
-- \"Unknown Error\" as a reason.
newFailureDetails ::
  FailureDetails
newFailureDetails :: FailureDetails
newFailureDetails =
  FailureDetails'
    { $sel:logFile:FailureDetails' :: Maybe Text
logFile = forall a. Maybe a
Prelude.Nothing,
      $sel:message:FailureDetails' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:reason:FailureDetails' :: Maybe Text
reason = forall a. Maybe a
Prelude.Nothing
    }

-- | The path to the log file where the step failure root cause was
-- originally recorded.
failureDetails_logFile :: Lens.Lens' FailureDetails (Prelude.Maybe Prelude.Text)
failureDetails_logFile :: Lens' FailureDetails (Maybe Text)
failureDetails_logFile = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {Maybe Text
logFile :: Maybe Text
$sel:logFile:FailureDetails' :: FailureDetails -> Maybe Text
logFile} -> Maybe Text
logFile) (\s :: FailureDetails
s@FailureDetails' {} Maybe Text
a -> FailureDetails
s {$sel:logFile:FailureDetails' :: Maybe Text
logFile = Maybe Text
a} :: FailureDetails)

-- | The descriptive message including the error the Amazon EMR service has
-- identified as the cause of step failure. This is text from an error log
-- that describes the root cause of the failure.
failureDetails_message :: Lens.Lens' FailureDetails (Prelude.Maybe Prelude.Text)
failureDetails_message :: Lens' FailureDetails (Maybe Text)
failureDetails_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {Maybe Text
message :: Maybe Text
$sel:message:FailureDetails' :: FailureDetails -> Maybe Text
message} -> Maybe Text
message) (\s :: FailureDetails
s@FailureDetails' {} Maybe Text
a -> FailureDetails
s {$sel:message:FailureDetails' :: Maybe Text
message = Maybe Text
a} :: FailureDetails)

-- | The reason for the step failure. In the case where the service cannot
-- successfully determine the root cause of the failure, it returns
-- \"Unknown Error\" as a reason.
failureDetails_reason :: Lens.Lens' FailureDetails (Prelude.Maybe Prelude.Text)
failureDetails_reason :: Lens' FailureDetails (Maybe Text)
failureDetails_reason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {Maybe Text
reason :: Maybe Text
$sel:reason:FailureDetails' :: FailureDetails -> Maybe Text
reason} -> Maybe Text
reason) (\s :: FailureDetails
s@FailureDetails' {} Maybe Text
a -> FailureDetails
s {$sel:reason:FailureDetails' :: Maybe Text
reason = Maybe Text
a} :: FailureDetails)

instance Data.FromJSON FailureDetails where
  parseJSON :: Value -> Parser FailureDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FailureDetails"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> FailureDetails
FailureDetails'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LogFile")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Message")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Reason")
      )

instance Prelude.Hashable FailureDetails where
  hashWithSalt :: Int -> FailureDetails -> Int
hashWithSalt Int
_salt FailureDetails' {Maybe Text
reason :: Maybe Text
message :: Maybe Text
logFile :: Maybe Text
$sel:reason:FailureDetails' :: FailureDetails -> Maybe Text
$sel:message:FailureDetails' :: FailureDetails -> Maybe Text
$sel:logFile:FailureDetails' :: FailureDetails -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logFile
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reason

instance Prelude.NFData FailureDetails where
  rnf :: FailureDetails -> ()
rnf FailureDetails' {Maybe Text
reason :: Maybe Text
message :: Maybe Text
logFile :: Maybe Text
$sel:reason:FailureDetails' :: FailureDetails -> Maybe Text
$sel:message:FailureDetails' :: FailureDetails -> Maybe Text
$sel:logFile:FailureDetails' :: FailureDetails -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logFile
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reason