jaberbu / onfirework

Makes Firebase easy to use
Other
0 stars 0 forks source link

Reject with Error #9

Closed ezequieltejada closed 3 years ago

ezequieltejada commented 3 years ago

Now that there is a Linter, a couple of problems came up.

The first one is this one: Expected the Promise rejection reason to be an Error.eslint(prefer-promise-reject-errors)

That can be found in multiple places where a Promise is rejected with anything besides an Error.

image

ezequieltejada commented 3 years ago

Here seems to be a couple of good reasons (Reason 1, Reason 2) to implement this.

The error catching (and therefore, setting the status code) should be dealt within the app that consumes the library. Because not all rejections must be a 500, right?

jaberbu commented 3 years ago

I understand that the errors shown by Linter would be solved by changing .catch((err: any) => reject({status: 500, data: { message: 'Internal Server Error !', err }})); to
.catch((err: any) => reject(err));

ezequieltejada commented 3 years ago

If that's the case, "err" should be typed as an Error object, and an Error should be thrown where is needed. Please let me know and I'll refactor each "catch"

jaberbu commented 3 years ago

Issue implement in #10 PR