{-# 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.Location.Types.RouteMatrixEntryError
-- 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.Location.Types.RouteMatrixEntryError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Location.Types.RouteMatrixErrorCode
import qualified Amazonka.Prelude as Prelude

-- | An error corresponding to the calculation of a route between the
-- @DeparturePosition@ and @DestinationPosition@.
--
-- The error code can be one of the following:
--
-- -   @RouteNotFound@ - Unable to find a valid route with the given
--     parameters.
--
-- -   @RouteTooLong@ - Route calculation went beyond the maximum size of a
--     route and was terminated before completion.
--
-- -   @PositionsNotFound@ - One or more of the input positions were not
--     found on the route network.
--
-- -   @DestinationPositionNotFound@ - The destination position was not
--     found on the route network.
--
-- -   @DeparturePositionNotFound@ - The departure position was not found
--     on the route network.
--
-- -   @OtherValidationError@ - The given inputs were not valid or a route
--     was not found. More information is given in the error @Message@
--
-- /See:/ 'newRouteMatrixEntryError' smart constructor.
data RouteMatrixEntryError = RouteMatrixEntryError'
  { -- | A message about the error that occurred for the route calculation.
    RouteMatrixEntryError -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The type of error which occurred for the route calculation.
    RouteMatrixEntryError -> RouteMatrixErrorCode
code :: RouteMatrixErrorCode
  }
  deriving (RouteMatrixEntryError -> RouteMatrixEntryError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RouteMatrixEntryError -> RouteMatrixEntryError -> Bool
$c/= :: RouteMatrixEntryError -> RouteMatrixEntryError -> Bool
== :: RouteMatrixEntryError -> RouteMatrixEntryError -> Bool
$c== :: RouteMatrixEntryError -> RouteMatrixEntryError -> Bool
Prelude.Eq, ReadPrec [RouteMatrixEntryError]
ReadPrec RouteMatrixEntryError
Int -> ReadS RouteMatrixEntryError
ReadS [RouteMatrixEntryError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RouteMatrixEntryError]
$creadListPrec :: ReadPrec [RouteMatrixEntryError]
readPrec :: ReadPrec RouteMatrixEntryError
$creadPrec :: ReadPrec RouteMatrixEntryError
readList :: ReadS [RouteMatrixEntryError]
$creadList :: ReadS [RouteMatrixEntryError]
readsPrec :: Int -> ReadS RouteMatrixEntryError
$creadsPrec :: Int -> ReadS RouteMatrixEntryError
Prelude.Read, Int -> RouteMatrixEntryError -> ShowS
[RouteMatrixEntryError] -> ShowS
RouteMatrixEntryError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RouteMatrixEntryError] -> ShowS
$cshowList :: [RouteMatrixEntryError] -> ShowS
show :: RouteMatrixEntryError -> String
$cshow :: RouteMatrixEntryError -> String
showsPrec :: Int -> RouteMatrixEntryError -> ShowS
$cshowsPrec :: Int -> RouteMatrixEntryError -> ShowS
Prelude.Show, forall x. Rep RouteMatrixEntryError x -> RouteMatrixEntryError
forall x. RouteMatrixEntryError -> Rep RouteMatrixEntryError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RouteMatrixEntryError x -> RouteMatrixEntryError
$cfrom :: forall x. RouteMatrixEntryError -> Rep RouteMatrixEntryError x
Prelude.Generic)

-- |
-- Create a value of 'RouteMatrixEntryError' 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', 'routeMatrixEntryError_message' - A message about the error that occurred for the route calculation.
--
-- 'code', 'routeMatrixEntryError_code' - The type of error which occurred for the route calculation.
newRouteMatrixEntryError ::
  -- | 'code'
  RouteMatrixErrorCode ->
  RouteMatrixEntryError
newRouteMatrixEntryError :: RouteMatrixErrorCode -> RouteMatrixEntryError
newRouteMatrixEntryError RouteMatrixErrorCode
pCode_ =
  RouteMatrixEntryError'
    { $sel:message:RouteMatrixEntryError' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:code:RouteMatrixEntryError' :: RouteMatrixErrorCode
code = RouteMatrixErrorCode
pCode_
    }

-- | A message about the error that occurred for the route calculation.
routeMatrixEntryError_message :: Lens.Lens' RouteMatrixEntryError (Prelude.Maybe Prelude.Text)
routeMatrixEntryError_message :: Lens' RouteMatrixEntryError (Maybe Text)
routeMatrixEntryError_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteMatrixEntryError' {Maybe Text
message :: Maybe Text
$sel:message:RouteMatrixEntryError' :: RouteMatrixEntryError -> Maybe Text
message} -> Maybe Text
message) (\s :: RouteMatrixEntryError
s@RouteMatrixEntryError' {} Maybe Text
a -> RouteMatrixEntryError
s {$sel:message:RouteMatrixEntryError' :: Maybe Text
message = Maybe Text
a} :: RouteMatrixEntryError)

-- | The type of error which occurred for the route calculation.
routeMatrixEntryError_code :: Lens.Lens' RouteMatrixEntryError RouteMatrixErrorCode
routeMatrixEntryError_code :: Lens' RouteMatrixEntryError RouteMatrixErrorCode
routeMatrixEntryError_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteMatrixEntryError' {RouteMatrixErrorCode
code :: RouteMatrixErrorCode
$sel:code:RouteMatrixEntryError' :: RouteMatrixEntryError -> RouteMatrixErrorCode
code} -> RouteMatrixErrorCode
code) (\s :: RouteMatrixEntryError
s@RouteMatrixEntryError' {} RouteMatrixErrorCode
a -> RouteMatrixEntryError
s {$sel:code:RouteMatrixEntryError' :: RouteMatrixErrorCode
code = RouteMatrixErrorCode
a} :: RouteMatrixEntryError)

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

instance Prelude.Hashable RouteMatrixEntryError where
  hashWithSalt :: Int -> RouteMatrixEntryError -> Int
hashWithSalt Int
_salt RouteMatrixEntryError' {Maybe Text
RouteMatrixErrorCode
code :: RouteMatrixErrorCode
message :: Maybe Text
$sel:code:RouteMatrixEntryError' :: RouteMatrixEntryError -> RouteMatrixErrorCode
$sel:message:RouteMatrixEntryError' :: RouteMatrixEntryError -> 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` RouteMatrixErrorCode
code

instance Prelude.NFData RouteMatrixEntryError where
  rnf :: RouteMatrixEntryError -> ()
rnf RouteMatrixEntryError' {Maybe Text
RouteMatrixErrorCode
code :: RouteMatrixErrorCode
message :: Maybe Text
$sel:code:RouteMatrixEntryError' :: RouteMatrixEntryError -> RouteMatrixErrorCode
$sel:message:RouteMatrixEntryError' :: RouteMatrixEntryError -> 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 RouteMatrixErrorCode
code