{-# LANGUAGE DeriveAnyClass #-}
{-|
Module: IHP.Router.Types
Copyright: (c) digitally induced GmbH, 2020
-}
module IHP.Router.Types where

import IHP.Prelude
import Network.HTTP.Types.Method

data TypedAutoRouteError
    = BadType
        { TypedAutoRouteError -> ByteString
expectedType :: !ByteString
        , TypedAutoRouteError -> Maybe ByteString
value :: !(Maybe ByteString)
        , TypedAutoRouteError -> ByteString
field :: !ByteString
        }
    | TooFewArguments
    | NotMatched
    -- | Thrown when 'IHP.RouterSupport.parseUUIDArgument', 'IHP.RouterSupport.parseIntArgument', etc. get passed an invalid value
    --
    -- Let's say we have a @ShowProjectAction { id :: Id Project }@.
    --
    -- When opening @/ShowProject?projectId=ab55d579-80cd-4608-9a8f-c76dea6c2332@ everything is fine.
    -- But when opening @/ShowProject?projectId=not-an-uuid@ this exception will be thrown.
    | NoConstructorMatched
        { expectedType :: !ByteString
        , value :: !(Maybe ByteString)
        , field :: !ByteString
        }
    deriving (Int -> TypedAutoRouteError -> ShowS
[TypedAutoRouteError] -> ShowS
TypedAutoRouteError -> String
(Int -> TypedAutoRouteError -> ShowS)
-> (TypedAutoRouteError -> String)
-> ([TypedAutoRouteError] -> ShowS)
-> Show TypedAutoRouteError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TypedAutoRouteError] -> ShowS
$cshowList :: [TypedAutoRouteError] -> ShowS
show :: TypedAutoRouteError -> String
$cshow :: TypedAutoRouteError -> String
showsPrec :: Int -> TypedAutoRouteError -> ShowS
$cshowsPrec :: Int -> TypedAutoRouteError -> ShowS
Show, Show TypedAutoRouteError
Typeable TypedAutoRouteError
Typeable TypedAutoRouteError
-> Show TypedAutoRouteError
-> (TypedAutoRouteError -> SomeException)
-> (SomeException -> Maybe TypedAutoRouteError)
-> (TypedAutoRouteError -> String)
-> Exception TypedAutoRouteError
SomeException -> Maybe TypedAutoRouteError
TypedAutoRouteError -> String
TypedAutoRouteError -> SomeException
forall e.
Typeable e
-> Show e
-> (e -> SomeException)
-> (SomeException -> Maybe e)
-> (e -> String)
-> Exception e
displayException :: TypedAutoRouteError -> String
$cdisplayException :: TypedAutoRouteError -> String
fromException :: SomeException -> Maybe TypedAutoRouteError
$cfromException :: SomeException -> Maybe TypedAutoRouteError
toException :: TypedAutoRouteError -> SomeException
$ctoException :: TypedAutoRouteError -> SomeException
$cp2Exception :: Show TypedAutoRouteError
$cp1Exception :: Typeable TypedAutoRouteError
Exception)

-- | Thrown e.g. a @CreateProjectAction@ is called from a GET request
--
data UnexpectedMethodException
    = UnexpectedMethodException
    { UnexpectedMethodException -> [StdMethod]
allowedMethods :: [StdMethod]
    , UnexpectedMethodException -> StdMethod
method :: StdMethod
    }
    deriving (Int -> UnexpectedMethodException -> ShowS
[UnexpectedMethodException] -> ShowS
UnexpectedMethodException -> String
(Int -> UnexpectedMethodException -> ShowS)
-> (UnexpectedMethodException -> String)
-> ([UnexpectedMethodException] -> ShowS)
-> Show UnexpectedMethodException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnexpectedMethodException] -> ShowS
$cshowList :: [UnexpectedMethodException] -> ShowS
show :: UnexpectedMethodException -> String
$cshow :: UnexpectedMethodException -> String
showsPrec :: Int -> UnexpectedMethodException -> ShowS
$cshowsPrec :: Int -> UnexpectedMethodException -> ShowS
Show, Show UnexpectedMethodException
Typeable UnexpectedMethodException
Typeable UnexpectedMethodException
-> Show UnexpectedMethodException
-> (UnexpectedMethodException -> SomeException)
-> (SomeException -> Maybe UnexpectedMethodException)
-> (UnexpectedMethodException -> String)
-> Exception UnexpectedMethodException
SomeException -> Maybe UnexpectedMethodException
UnexpectedMethodException -> String
UnexpectedMethodException -> SomeException
forall e.
Typeable e
-> Show e
-> (e -> SomeException)
-> (SomeException -> Maybe e)
-> (e -> String)
-> Exception e
displayException :: UnexpectedMethodException -> String
$cdisplayException :: UnexpectedMethodException -> String
fromException :: SomeException -> Maybe UnexpectedMethodException
$cfromException :: SomeException -> Maybe UnexpectedMethodException
toException :: UnexpectedMethodException -> SomeException
$ctoException :: UnexpectedMethodException -> SomeException
$cp2Exception :: Show UnexpectedMethodException
$cp1Exception :: Typeable UnexpectedMethodException
Exception)