{-# 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.Athena.Types.AthenaError
-- 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.Athena.Types.AthenaError 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

-- | Provides information about an Athena query error. The @AthenaError@
-- feature provides standardized error information to help you understand
-- failed queries and take steps after a query failure occurs.
-- @AthenaError@ includes an @ErrorCategory@ field that specifies whether
-- the cause of the failed query is due to system error, user error, or
-- other error.
--
-- /See:/ 'newAthenaError' smart constructor.
data AthenaError = AthenaError'
  { -- | An integer value that specifies the category of a query failure error.
    -- The following list shows the category for each integer value.
    --
    -- __1__ - System
    --
    -- __2__ - User
    --
    -- __3__ - Other
    AthenaError -> Maybe Natural
errorCategory :: Prelude.Maybe Prelude.Natural,
    -- | Contains a short description of the error that occurred.
    AthenaError -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | An integer value that provides specific information about an Athena
    -- query error. For the meaning of specific values, see the
    -- <https://docs.aws.amazon.com/athena/latest/ug/error-reference.html#error-reference-error-type-reference Error Type Reference>
    -- in the /Amazon Athena User Guide/.
    AthenaError -> Maybe Natural
errorType :: Prelude.Maybe Prelude.Natural,
    -- | True if the query might succeed if resubmitted.
    AthenaError -> Maybe Bool
retryable :: Prelude.Maybe Prelude.Bool
  }
  deriving (AthenaError -> AthenaError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AthenaError -> AthenaError -> Bool
$c/= :: AthenaError -> AthenaError -> Bool
== :: AthenaError -> AthenaError -> Bool
$c== :: AthenaError -> AthenaError -> Bool
Prelude.Eq, ReadPrec [AthenaError]
ReadPrec AthenaError
Int -> ReadS AthenaError
ReadS [AthenaError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AthenaError]
$creadListPrec :: ReadPrec [AthenaError]
readPrec :: ReadPrec AthenaError
$creadPrec :: ReadPrec AthenaError
readList :: ReadS [AthenaError]
$creadList :: ReadS [AthenaError]
readsPrec :: Int -> ReadS AthenaError
$creadsPrec :: Int -> ReadS AthenaError
Prelude.Read, Int -> AthenaError -> ShowS
[AthenaError] -> ShowS
AthenaError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AthenaError] -> ShowS
$cshowList :: [AthenaError] -> ShowS
show :: AthenaError -> String
$cshow :: AthenaError -> String
showsPrec :: Int -> AthenaError -> ShowS
$cshowsPrec :: Int -> AthenaError -> ShowS
Prelude.Show, forall x. Rep AthenaError x -> AthenaError
forall x. AthenaError -> Rep AthenaError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AthenaError x -> AthenaError
$cfrom :: forall x. AthenaError -> Rep AthenaError x
Prelude.Generic)

-- |
-- Create a value of 'AthenaError' 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:
--
-- 'errorCategory', 'athenaError_errorCategory' - An integer value that specifies the category of a query failure error.
-- The following list shows the category for each integer value.
--
-- __1__ - System
--
-- __2__ - User
--
-- __3__ - Other
--
-- 'errorMessage', 'athenaError_errorMessage' - Contains a short description of the error that occurred.
--
-- 'errorType', 'athenaError_errorType' - An integer value that provides specific information about an Athena
-- query error. For the meaning of specific values, see the
-- <https://docs.aws.amazon.com/athena/latest/ug/error-reference.html#error-reference-error-type-reference Error Type Reference>
-- in the /Amazon Athena User Guide/.
--
-- 'retryable', 'athenaError_retryable' - True if the query might succeed if resubmitted.
newAthenaError ::
  AthenaError
newAthenaError :: AthenaError
newAthenaError =
  AthenaError'
    { $sel:errorCategory:AthenaError' :: Maybe Natural
errorCategory = forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:AthenaError' :: Maybe Text
errorMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:errorType:AthenaError' :: Maybe Natural
errorType = forall a. Maybe a
Prelude.Nothing,
      $sel:retryable:AthenaError' :: Maybe Bool
retryable = forall a. Maybe a
Prelude.Nothing
    }

-- | An integer value that specifies the category of a query failure error.
-- The following list shows the category for each integer value.
--
-- __1__ - System
--
-- __2__ - User
--
-- __3__ - Other
athenaError_errorCategory :: Lens.Lens' AthenaError (Prelude.Maybe Prelude.Natural)
athenaError_errorCategory :: Lens' AthenaError (Maybe Natural)
athenaError_errorCategory = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaError' {Maybe Natural
errorCategory :: Maybe Natural
$sel:errorCategory:AthenaError' :: AthenaError -> Maybe Natural
errorCategory} -> Maybe Natural
errorCategory) (\s :: AthenaError
s@AthenaError' {} Maybe Natural
a -> AthenaError
s {$sel:errorCategory:AthenaError' :: Maybe Natural
errorCategory = Maybe Natural
a} :: AthenaError)

-- | Contains a short description of the error that occurred.
athenaError_errorMessage :: Lens.Lens' AthenaError (Prelude.Maybe Prelude.Text)
athenaError_errorMessage :: Lens' AthenaError (Maybe Text)
athenaError_errorMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaError' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:AthenaError' :: AthenaError -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: AthenaError
s@AthenaError' {} Maybe Text
a -> AthenaError
s {$sel:errorMessage:AthenaError' :: Maybe Text
errorMessage = Maybe Text
a} :: AthenaError)

-- | An integer value that provides specific information about an Athena
-- query error. For the meaning of specific values, see the
-- <https://docs.aws.amazon.com/athena/latest/ug/error-reference.html#error-reference-error-type-reference Error Type Reference>
-- in the /Amazon Athena User Guide/.
athenaError_errorType :: Lens.Lens' AthenaError (Prelude.Maybe Prelude.Natural)
athenaError_errorType :: Lens' AthenaError (Maybe Natural)
athenaError_errorType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaError' {Maybe Natural
errorType :: Maybe Natural
$sel:errorType:AthenaError' :: AthenaError -> Maybe Natural
errorType} -> Maybe Natural
errorType) (\s :: AthenaError
s@AthenaError' {} Maybe Natural
a -> AthenaError
s {$sel:errorType:AthenaError' :: Maybe Natural
errorType = Maybe Natural
a} :: AthenaError)

-- | True if the query might succeed if resubmitted.
athenaError_retryable :: Lens.Lens' AthenaError (Prelude.Maybe Prelude.Bool)
athenaError_retryable :: Lens' AthenaError (Maybe Bool)
athenaError_retryable = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaError' {Maybe Bool
retryable :: Maybe Bool
$sel:retryable:AthenaError' :: AthenaError -> Maybe Bool
retryable} -> Maybe Bool
retryable) (\s :: AthenaError
s@AthenaError' {} Maybe Bool
a -> AthenaError
s {$sel:retryable:AthenaError' :: Maybe Bool
retryable = Maybe Bool
a} :: AthenaError)

instance Data.FromJSON AthenaError where
  parseJSON :: Value -> Parser AthenaError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AthenaError"
      ( \Object
x ->
          Maybe Natural
-> Maybe Text -> Maybe Natural -> Maybe Bool -> AthenaError
AthenaError'
            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
"ErrorCategory")
            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
"ErrorMessage")
            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
"ErrorType")
            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
"Retryable")
      )

instance Prelude.Hashable AthenaError where
  hashWithSalt :: Int -> AthenaError -> Int
hashWithSalt Int
_salt AthenaError' {Maybe Bool
Maybe Natural
Maybe Text
retryable :: Maybe Bool
errorType :: Maybe Natural
errorMessage :: Maybe Text
errorCategory :: Maybe Natural
$sel:retryable:AthenaError' :: AthenaError -> Maybe Bool
$sel:errorType:AthenaError' :: AthenaError -> Maybe Natural
$sel:errorMessage:AthenaError' :: AthenaError -> Maybe Text
$sel:errorCategory:AthenaError' :: AthenaError -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
errorCategory
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
errorType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
retryable

instance Prelude.NFData AthenaError where
  rnf :: AthenaError -> ()
rnf AthenaError' {Maybe Bool
Maybe Natural
Maybe Text
retryable :: Maybe Bool
errorType :: Maybe Natural
errorMessage :: Maybe Text
errorCategory :: Maybe Natural
$sel:retryable:AthenaError' :: AthenaError -> Maybe Bool
$sel:errorType:AthenaError' :: AthenaError -> Maybe Natural
$sel:errorMessage:AthenaError' :: AthenaError -> Maybe Text
$sel:errorCategory:AthenaError' :: AthenaError -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
errorCategory
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
errorType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
retryable