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

Single global error method #8

Open
MattIPv4 opened this issue Oct 6, 2019 · 0 comments

Comments

@MattIPv4
Copy link
Member

commented Oct 6, 2019

Website/API Suggestion

Description

The beginnings of this already exist in src/Util/handleError.js but currently this only handles logging the error to the database.

It would be great if this also handled sending the correct response to the web request so that we can reduce code duplication on all routes that catch errors.

This needs to consider that website routes will want an HTML 500 response but for all API routes, they will expect a JSON response.

Example website usage: src/Routes/Lists.js#L44-L45
Example API usage: src/Routes/API.js#L92-L97

Why

Code duplication is a pain and we want to ensure all errors across the site return a consistent response (API should have a consistent JSON response too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.