{-# 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.QuickSight.Types.ErrorInfo
-- 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.QuickSight.Types.ErrorInfo 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.QuickSight.Types.IngestionErrorType

-- | Error information for the SPICE ingestion of a dataset.
--
-- /See:/ 'newErrorInfo' smart constructor.
data ErrorInfo = ErrorInfo'
  { -- | Error message.
    ErrorInfo -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | Error type.
    ErrorInfo -> Maybe IngestionErrorType
type' :: Prelude.Maybe IngestionErrorType
  }
  deriving (ErrorInfo -> ErrorInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorInfo -> ErrorInfo -> Bool
$c/= :: ErrorInfo -> ErrorInfo -> Bool
== :: ErrorInfo -> ErrorInfo -> Bool
$c== :: ErrorInfo -> ErrorInfo -> Bool
Prelude.Eq, ReadPrec [ErrorInfo]
ReadPrec ErrorInfo
Int -> ReadS ErrorInfo
ReadS [ErrorInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorInfo]
$creadListPrec :: ReadPrec [ErrorInfo]
readPrec :: ReadPrec ErrorInfo
$creadPrec :: ReadPrec ErrorInfo
readList :: ReadS [ErrorInfo]
$creadList :: ReadS [ErrorInfo]
readsPrec :: Int -> ReadS ErrorInfo
$creadsPrec :: Int -> ReadS ErrorInfo
Prelude.Read, Int -> ErrorInfo -> ShowS
[ErrorInfo] -> ShowS
ErrorInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorInfo] -> ShowS
$cshowList :: [ErrorInfo] -> ShowS
show :: ErrorInfo -> String
$cshow :: ErrorInfo -> String
showsPrec :: Int -> ErrorInfo -> ShowS
$cshowsPrec :: Int -> ErrorInfo -> ShowS
Prelude.Show, forall x. Rep ErrorInfo x -> ErrorInfo
forall x. ErrorInfo -> Rep ErrorInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorInfo x -> ErrorInfo
$cfrom :: forall x. ErrorInfo -> Rep ErrorInfo x
Prelude.Generic)

-- |
-- Create a value of 'ErrorInfo' 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:
--
-- 'message', 'errorInfo_message' - Error message.
--
-- 'type'', 'errorInfo_type' - Error type.
newErrorInfo ::
  ErrorInfo
newErrorInfo :: ErrorInfo
newErrorInfo =
  ErrorInfo'
    { $sel:message:ErrorInfo' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ErrorInfo' :: Maybe IngestionErrorType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | Error message.
errorInfo_message :: Lens.Lens' ErrorInfo (Prelude.Maybe Prelude.Text)
errorInfo_message :: Lens' ErrorInfo (Maybe Text)
errorInfo_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorInfo' {Maybe Text
message :: Maybe Text
$sel:message:ErrorInfo' :: ErrorInfo -> Maybe Text
message} -> Maybe Text
message) (\s :: ErrorInfo
s@ErrorInfo' {} Maybe Text
a -> ErrorInfo
s {$sel:message:ErrorInfo' :: Maybe Text
message = Maybe Text
a} :: ErrorInfo)

-- | Error type.
errorInfo_type :: Lens.Lens' ErrorInfo (Prelude.Maybe IngestionErrorType)
errorInfo_type :: Lens' ErrorInfo (Maybe IngestionErrorType)
errorInfo_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorInfo' {Maybe IngestionErrorType
type' :: Maybe IngestionErrorType
$sel:type':ErrorInfo' :: ErrorInfo -> Maybe IngestionErrorType
type'} -> Maybe IngestionErrorType
type') (\s :: ErrorInfo
s@ErrorInfo' {} Maybe IngestionErrorType
a -> ErrorInfo
s {$sel:type':ErrorInfo' :: Maybe IngestionErrorType
type' = Maybe IngestionErrorType
a} :: ErrorInfo)

instance Data.FromJSON ErrorInfo where
  parseJSON :: Value -> Parser ErrorInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ErrorInfo"
      ( \Object
x ->
          Maybe Text -> Maybe IngestionErrorType -> ErrorInfo
ErrorInfo'
            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
"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
"Type")
      )

instance Prelude.Hashable ErrorInfo where
  hashWithSalt :: Int -> ErrorInfo -> Int
hashWithSalt Int
_salt ErrorInfo' {Maybe Text
Maybe IngestionErrorType
type' :: Maybe IngestionErrorType
message :: Maybe Text
$sel:type':ErrorInfo' :: ErrorInfo -> Maybe IngestionErrorType
$sel:message:ErrorInfo' :: ErrorInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IngestionErrorType
type'

instance Prelude.NFData ErrorInfo where
  rnf :: ErrorInfo -> ()
rnf ErrorInfo' {Maybe Text
Maybe IngestionErrorType
type' :: Maybe IngestionErrorType
message :: Maybe Text
$sel:type':ErrorInfo' :: ErrorInfo -> Maybe IngestionErrorType
$sel:message:ErrorInfo' :: ErrorInfo -> Maybe Text
..} =
    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 IngestionErrorType
type'