From 067914aac0a12aaf1c6da76a8400b3cd6579a0bb Mon Sep 17 00:00:00 2001 From: Maximilian Tagher Date: Tue, 6 Oct 2020 10:41:03 -0400 Subject: [PATCH 1/2] Document ErrorResponse --- yesod-core/ChangeLog.md | 4 ++++ yesod-core/src/Yesod/Core/Types.hs | 17 +++++++++++++++++ yesod-core/yesod-core.cabal | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/yesod-core/ChangeLog.md b/yesod-core/ChangeLog.md index fbb4c521..be3d49f3 100644 --- a/yesod-core/ChangeLog.md +++ b/yesod-core/ChangeLog.md @@ -1,5 +1,9 @@ # ChangeLog for yesod-core +## 1.6.18.5 + +Document `ErrorResponse` []() + ## 1.6.18.4 * Fixed a bug where `mkYesod` and other TH functions didn't work for datatypes with explicitly stated type variables, including the case with typeclass constraints. [https://github.com/yesodweb/yesod/pull/1697](#1697) diff --git a/yesod-core/src/Yesod/Core/Types.hs b/yesod-core/src/Yesod/Core/Types.hs index db7c48a9..7d55b358 100644 --- a/yesod-core/src/Yesod/Core/Types.hs +++ b/yesod-core/src/Yesod/Core/Types.hs @@ -326,11 +326,28 @@ newtype DontFullyEvaluate a = DontFullyEvaluate { unDontFullyEvaluate :: a } -- | Responses to indicate some form of an error occurred. data ErrorResponse = NotFound + -- ^ The requested resource was not found. + -- Examples of when this occurs include when an incorrect URL is used, or @yesod-persistent@'s 'get404' doesn't find a value. + -- HTTP status: 404. | InternalError !Text + -- ^ Some sort of unexpected exception. + -- If your application uses `throwIO` or `error` to throw an exception, this is the form it would take. + -- HTTP status: 500. | InvalidArgs ![Text] + -- ^ Indicates some sort of invalid or missing argument, like a missing query parameter or malformed JSON body. + -- Examples Yesod functions that send this include 'requireCheckJsonBody' and @Yesod.Auth.GoogleEmail2@. + -- HTTP status: 400. | NotAuthenticated + -- ^ Indicates the user is not logged in. + -- This is thrown when 'isAuthorized' returns 'AuthenticationRequired'. + -- HTTP code: 401. | PermissionDenied !Text + -- ^ Indicates the user doesn't have permission to access the requested resource. + -- This is thrown when 'isAuthorized' returns 'Unauthorized'. + -- HTTP code: 403. | BadMethod !H.Method + -- ^ Indicates the URL would have been valid if used with a different HTTP method (e.g. a GET was used, but only POST is handled.) + -- HTTP code: 405. deriving (Show, Eq, Generic) instance NFData ErrorResponse diff --git a/yesod-core/yesod-core.cabal b/yesod-core/yesod-core.cabal index e63819a4..d88b0418 100644 --- a/yesod-core/yesod-core.cabal +++ b/yesod-core/yesod-core.cabal @@ -1,5 +1,5 @@ name: yesod-core -version: 1.6.18.4 +version: 1.6.18.5 license: MIT license-file: LICENSE author: Michael Snoyman From 24061e18bd0559922c158ec19ee20369698f7f4c Mon Sep 17 00:00:00 2001 From: Maximilian Tagher Date: Tue, 6 Oct 2020 10:41:53 -0400 Subject: [PATCH 2/2] .. --- yesod-core/ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yesod-core/ChangeLog.md b/yesod-core/ChangeLog.md index be3d49f3..d8564ece 100644 --- a/yesod-core/ChangeLog.md +++ b/yesod-core/ChangeLog.md @@ -2,7 +2,7 @@ ## 1.6.18.5 -Document `ErrorResponse` []() +Document `ErrorResponse` [#1698](https://github.com/yesodweb/yesod/pull/1698) ## 1.6.18.4