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

Error-handling best practice #32

Open
LiviaValenti opened this issue Mar 11, 2022 · 1 comment
Open

Error-handling best practice #32

LiviaValenti opened this issue Mar 11, 2022 · 1 comment
Labels
backend 🍑 Backend tasks discussion 💭 Requires more thought help wanted 👋 Extra attention is needed

Comments

@LiviaValenti
Copy link
Collaborator

Is it best practice requiring importing from the package twice? Should the package even export error functionality instead of just throwing errors with messages to the developer to handle?

Originally posted by @Xtrah in #29 (comment)

@eivindkopperud
Copy link
Member

I've had a look at this now, and I feel like it makes more sense to define CustomError (or something else) inside NTNUI/opptak, and not export it from NTNUI/ntnui-tools. There are some places where several responses with status code 400 can be sent, e.g.:

  1. I try to log in with wrong credentials, and get a 400 error
  2. I try to log in with correct credentials, but I have no committee memberships, and I get a 400 error

It would be nice to have a errorCode: INVALID_CREDENTIALS and a errorCode: MISSING_COMMITTEE_MEMBERSHIP, such that the frontend can catch both and display a better message. Currently I get a "the user is not found" for both the cases.

This logic does not really have anything to do with ntnui-tools, so CustomError should be defined in NTNUI/opptak.

@Xtrah Xtrah added help wanted 👋 Extra attention is needed backend 🍑 Backend tasks labels May 4, 2022
@eivindkopperud eivindkopperud added the discussion 💭 Requires more thought label May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend 🍑 Backend tasks discussion 💭 Requires more thought help wanted 👋 Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants