Skip to content

Feat/error handling#39

Merged
weiseng18 merged 4 commits intodevelopfrom
feat/error-handling
Aug 11, 2021
Merged

Feat/error handling#39
weiseng18 merged 4 commits intodevelopfrom
feat/error-handling

Conversation

@weiseng18
Copy link
Copy Markdown
Owner

@weiseng18 weiseng18 commented Aug 11, 2021

Problem

  1. The generic throw new Error was previously used, so all errors are 500. In the two locations it is used, a 400 should be thrown instead.
  2. The frontend page /matrix was not able to access the actual custom error message, instead it just says Request failed with status code 500

Solution

  1. Create a HttpException class that accepts a status code to throw non-500 errors easily, and update the two locations to throw a 400 instead.
  2. The actual error is located in err.response.data.message, and not err.message. Update the line

Checklist

  • If the branch was not created off latest develop, merge locally
  • Using latest develop and master, do git diff --stat master while in develop branch. Ensure that the diff is not too large

Notes

Considered writing a middleware to handle the errors, but that would require next() which is not part of Vercel's serverless functions structure. I could use next: Function, and it would work as expected. However, the API tests use vercel-node-server, which is not able to trigger next(), and rightfully so since it is not part of Vercel's serverless functions structure.

@vercel
Copy link
Copy Markdown

vercel Bot commented Aug 11, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/weiseng18/math/EnR8QkjFpYUrPXQvXWjMNLczQNpV
✅ Preview: https://math-git-feat-error-handling-weiseng18.vercel.app

@weiseng18 weiseng18 merged commit 46ba0a2 into develop Aug 11, 2021
@weiseng18 weiseng18 deleted the feat/error-handling branch August 11, 2021 15:04
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

Successfully merging this pull request may close these issues.

1 participant