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

consistent error message formatting #115

Open
hussu010 opened this issue Aug 27, 2022 · 3 comments
Open

consistent error message formatting #115

hussu010 opened this issue Aug 27, 2022 · 3 comments

Comments

@hussu010
Copy link
Collaborator

we need a document that outlines the error message format that we will be using for various types of error codes.

@wakawakathedev
Copy link
Collaborator

Create standard error codes and use those types and respond with those codes to the FE

@wakawakathedev
Copy link
Collaborator

Eg.

Type ErrorCodes = {
  Success = 200,
  Unauthorised = 401,
  NotFound = 404,
  Network = 500,
 
}

@amarjeet987
Copy link

amarjeet987 commented Aug 31, 2022

  1. Create a global error handler and place it below all the route handlers.
  2. Create error classes like NotFoundError, InternalServerError, etc and extend them from error. Override the statusCode and error message there.
  3. You can directly throw these errors from the apis. The error handler will catch them automatically where you can format them as required and send in the response.

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

No branches or pull requests

3 participants