8000 bug: fix status-code for store not found by michael-hoffman-26 · Pull Request #660 · configu/configu · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bug: fix status-code for store not found #660

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michael-hoffman-26
Copy link
Contributor

Closes #655

Summary

This MR fixes an issue where attempting to export a non-existing store returned an incorrect status code (500 instead of 404). The response now correctly returns a 404 status code with a message indicating that the store was not found.

Changes

  • Added a custom NotFoundError class to handle cases where a requested store does not exist.
  • Updated the controller to throw NotFoundError when the store is not found.
    Explanation:
    When an error is thrown in Fastify (like NotFoundError), the framework’s default error handler automatically intercepts it. If the error object includes a statusCode property, Fastify will set the response’s status code to this value. This means that by simply throwing an error with a custom statusCode, Fastify will correctly format and send the response based on the error's properties without needing extra configuration.
    see docs

Example Response

{
    "code": "FST_ERR_NOT_FOUND",
    "name": "NotFoundError",
    "message": "store \"mainStore\" not found",
    "statusCode": 404
}

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

Successfully merging this pull request may close these issues.

[Bug] Export API responds with 500 instead of 404 for non-existent store
1 participant
CB2
0