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

creatPostHandler: better error messages #21

Open
houssemAmiri opened this issue Sep 1, 2022 · 5 comments
Open

creatPostHandler: better error messages #21

houssemAmiri opened this issue Sep 1, 2022 · 5 comments

Comments

@houssemAmiri
Copy link
Contributor

No description provided.

@yebrahim
Copy link
Owner

yebrahim commented Sep 2, 2022

agreed, I think we could use some review of all error messages, and maybe better type-checking as well (maybe add an enum for errors?).

@houssemAmiri
Copy link
Contributor Author

I'm thinking about how to do it nest js have good error handling I'm trying to understand how it work and implement it here I will open a PR next days

@yebrahim
Copy link
Owner

yebrahim commented Sep 2, 2022

can you explain more what you have in mind? I thought you just meant going over the error strings we're returning to make sure they're useful.

@houssemAmiri
Copy link
Contributor Author

I suggest that we add using this library
https://express-validator.github.io/docs/
it's a middleware that wraps errors
also adding enum for error types
and classes to initiate common errors
example:
new HttpException('Forbidden', HttpStatus.FORBIDDEN);

export class ForbiddenException extends HttpException {
  constructor() {
    super('Forbidden', HttpStatus.FORBIDDEN);
  }
}

and
throw new ForbiddenException();
what do you think @yebrahim we can do this fo all errors

@yebrahim
Copy link
Owner

it's a good find.
the problem with these libraries is they're pretty opinionated, and they end up shaping your code in a way you don't necessarily like, and now newcomers to the codebase have to learn to use those and commit to them as well.
I think for a small project like this, we're better served rolling our own verification utilities, which won't be hard to do anyway.
let me know if you feel strongly about this though.

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

No branches or pull requests

2 participants