-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved error messages when a mandatory AutoRoute request parameter …
…is missing. Fixes #932
- Loading branch information
1 parent
28843ec
commit e713803
Showing
3 changed files
with
55 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-| | ||
Module: IHP.Router.Types | ||
Copyright: (c) digitally induced GmbH, 2020 | ||
-} | ||
module IHP.Router.Types where | ||
|
||
import IHP.Prelude | ||
import Control.Exception | ||
|
||
-- | 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. | ||
data InvalidActionArgumentException = InvalidActionArgumentException | ||
data TypedAutoRouteError | ||
= BadType | ||
{ expectedType :: !ByteString | ||
, value :: !ByteString | ||
, value :: !(Maybe ByteString) | ||
, field :: !ByteString | ||
} deriving (Eq, Show) | ||
|
||
instance Exception InvalidActionArgumentException | ||
} | ||
| 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 (Show, Exception) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters