Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultErrorFormatters doesn't format 404 #1790

Open
cblp opened this issue Oct 4, 2024 · 0 comments
Open

defaultErrorFormatters doesn't format 404 #1790

cblp opened this issue Oct 4, 2024 · 0 comments

Comments

@cblp
Copy link

cblp commented Oct 4, 2024

defaultErrorFormatters is documented as

Default formatters will just return HTTP 400 status code with error message as response body.

but its implementation is

defaultErrorFormatters = ...
    notFoundErrorFormatter = const err404

err404 = ...
    errBody = ""

So, in case of error 404, the message is not present in the response body.

Workaround

do
    serveWithContext api (errorFormatters :. EmptyContext)
  where
    errorFormatters = defaultErrorFormatters{notFoundErrorFormatter}
    notFoundErrorFormatter _ =
        ServerError
            { errHTTPCode = 404
            , errReasonPhrase = "Not Found"
            , errBody = "404 Not Found"
            , errHeaders = []
            }

Proposed solution

Change defaultErrorFormatters.notFoundErrorFormatter to errBody.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant