{-# 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.Transfer.Types.ExecutionError
-- 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.Transfer.Types.ExecutionError 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
import Amazonka.Transfer.Types.ExecutionErrorType

-- | Specifies the error message and type, for an error that occurs during
-- the execution of the workflow.
--
-- /See:/ 'newExecutionError' smart constructor.
data ExecutionError = ExecutionError'
  { -- | Specifies the error type.
    --
    -- -   @ALREADY_EXISTS@: occurs for a copy step, if the overwrite option is
    --     not selected and a file with the same name already exists in the
    --     target location.
    --
    -- -   @BAD_REQUEST@: a general bad request: for example, a step that
    --     attempts to tag an EFS file returns @BAD_REQUEST@, as only S3 files
    --     can be tagged.
    --
    -- -   @CUSTOM_STEP_FAILED@: occurs when the custom step provided a
    --     callback that indicates failure.
    --
    -- -   @INTERNAL_SERVER_ERROR@: a catch-all error that can occur for a
    --     variety of reasons.
    --
    -- -   @NOT_FOUND@: occurs when a requested entity, for example a source
    --     file for a copy step, does not exist.
    --
    -- -   @PERMISSION_DENIED@: occurs if your policy does not contain the
    --     correct permissions to complete one or more of the steps in the
    --     workflow.
    --
    -- -   @TIMEOUT@: occurs when the execution times out.
    --
    --     You can set the @TimeoutSeconds@ for a custom step, anywhere from 1
    --     second to 1800 seconds (30 minutes).
    --
    -- -   @THROTTLED@: occurs if you exceed the new execution refill rate of
    --     one workflow per second.
    ExecutionError -> ExecutionErrorType
type' :: ExecutionErrorType,
    -- | Specifies the descriptive message that corresponds to the @ErrorType@.
    ExecutionError -> Text
message :: Prelude.Text
  }
  deriving (ExecutionError -> ExecutionError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutionError -> ExecutionError -> Bool
$c/= :: ExecutionError -> ExecutionError -> Bool
== :: ExecutionError -> ExecutionError -> Bool
$c== :: ExecutionError -> ExecutionError -> Bool
Prelude.Eq, ReadPrec [ExecutionError]
ReadPrec ExecutionError
Int -> ReadS ExecutionError
ReadS [ExecutionError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutionError]
$creadListPrec :: ReadPrec [ExecutionError]
readPrec :: ReadPrec ExecutionError
$creadPrec :: ReadPrec ExecutionError
readList :: ReadS [ExecutionError]
$creadList :: ReadS [ExecutionError]
readsPrec :: Int -> ReadS ExecutionError
$creadsPrec :: Int -> ReadS ExecutionError
Prelude.Read, Int -> ExecutionError -> ShowS
[ExecutionError] -> ShowS
ExecutionError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutionError] -> ShowS
$cshowList :: [ExecutionError] -> ShowS
show :: ExecutionError -> String
$cshow :: ExecutionError -> String
showsPrec :: Int -> ExecutionError -> ShowS
$cshowsPrec :: Int -> ExecutionError -> ShowS
Prelude.Show, forall x. Rep ExecutionError x -> ExecutionError
forall x. ExecutionError -> Rep ExecutionError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutionError x -> ExecutionError
$cfrom :: forall x. ExecutionError -> Rep ExecutionError x
Prelude.Generic)

-- |
-- Create a value of 'ExecutionError' 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:
--
-- 'type'', 'executionError_type' - Specifies the error type.
--
-- -   @ALREADY_EXISTS@: occurs for a copy step, if the overwrite option is
--     not selected and a file with the same name already exists in the
--     target location.
--
-- -   @BAD_REQUEST@: a general bad request: for example, a step that
--     attempts to tag an EFS file returns @BAD_REQUEST@, as only S3 files
--     can be tagged.
--
-- -   @CUSTOM_STEP_FAILED@: occurs when the custom step provided a
--     callback that indicates failure.
--
-- -   @INTERNAL_SERVER_ERROR@: a catch-all error that can occur for a
--     variety of reasons.
--
-- -   @NOT_FOUND@: occurs when a requested entity, for example a source
--     file for a copy step, does not exist.
--
-- -   @PERMISSION_DENIED@: occurs if your policy does not contain the
--     correct permissions to complete one or more of the steps in the
--     workflow.
--
-- -   @TIMEOUT@: occurs when the execution times out.
--
--     You can set the @TimeoutSeconds@ for a custom step, anywhere from 1
--     second to 1800 seconds (30 minutes).
--
-- -   @THROTTLED@: occurs if you exceed the new execution refill rate of
--     one workflow per second.
--
-- 'message', 'executionError_message' - Specifies the descriptive message that corresponds to the @ErrorType@.
newExecutionError ::
  -- | 'type''
  ExecutionErrorType ->
  -- | 'message'
  Prelude.Text ->
  ExecutionError
newExecutionError :: ExecutionErrorType -> Text -> ExecutionError
newExecutionError ExecutionErrorType
pType_ Text
pMessage_ =
  ExecutionError'
    { $sel:type':ExecutionError' :: ExecutionErrorType
type' = ExecutionErrorType
pType_,
      $sel:message:ExecutionError' :: Text
message = Text
pMessage_
    }

-- | Specifies the error type.
--
-- -   @ALREADY_EXISTS@: occurs for a copy step, if the overwrite option is
--     not selected and a file with the same name already exists in the
--     target location.
--
-- -   @BAD_REQUEST@: a general bad request: for example, a step that
--     attempts to tag an EFS file returns @BAD_REQUEST@, as only S3 files
--     can be tagged.
--
-- -   @CUSTOM_STEP_FAILED@: occurs when the custom step provided a
--     callback that indicates failure.
--
-- -   @INTERNAL_SERVER_ERROR@: a catch-all error that can occur for a
--     variety of reasons.
--
-- -   @NOT_FOUND@: occurs when a requested entity, for example a source
--     file for a copy step, does not exist.
--
-- -   @PERMISSION_DENIED@: occurs if your policy does not contain the
--     correct permissions to complete one or more of the steps in the
--     workflow.
--
-- -   @TIMEOUT@: occurs when the execution times out.
--
--     You can set the @TimeoutSeconds@ for a custom step, anywhere from 1
--     second to 1800 seconds (30 minutes).
--
-- -   @THROTTLED@: occurs if you exceed the new execution refill rate of
--     one workflow per second.
executionError_type :: Lens.Lens' ExecutionError ExecutionErrorType
executionError_type :: Lens' ExecutionError ExecutionErrorType
executionError_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionError' {ExecutionErrorType
type' :: ExecutionErrorType
$sel:type':ExecutionError' :: ExecutionError -> ExecutionErrorType
type'} -> ExecutionErrorType
type') (\s :: ExecutionError
s@ExecutionError' {} ExecutionErrorType
a -> ExecutionError
s {$sel:type':ExecutionError' :: ExecutionErrorType
type' = ExecutionErrorType
a} :: ExecutionError)

-- | Specifies the descriptive message that corresponds to the @ErrorType@.
executionError_message :: Lens.Lens' ExecutionError Prelude.Text
executionError_message :: Lens' ExecutionError Text
executionError_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionError' {Text
message :: Text
$sel:message:ExecutionError' :: ExecutionError -> Text
message} -> Text
message) (\s :: ExecutionError
s@ExecutionError' {} Text
a -> ExecutionError
s {$sel:message:ExecutionError' :: Text
message = Text
a} :: ExecutionError)

instance Data.FromJSON ExecutionError where
  parseJSON :: Value -> Parser ExecutionError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ExecutionError"
      ( \Object
x ->
          ExecutionErrorType -> Text -> ExecutionError
ExecutionError'
            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
"Type")
            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 ExecutionError where
  hashWithSalt :: Int -> ExecutionError -> Int
hashWithSalt Int
_salt ExecutionError' {Text
ExecutionErrorType
message :: Text
type' :: ExecutionErrorType
$sel:message:ExecutionError' :: ExecutionError -> Text
$sel:type':ExecutionError' :: ExecutionError -> ExecutionErrorType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ExecutionErrorType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
message

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