-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
better error handling #12
Comments
@JohnDoePBabu what is your best approach for handling error? I didn't add the error handling while making the project since I want to understand how BMC API works. Do you have any suggestion since we are going to use GOT might has better error handling than request. |
Hi @JohnDoePBabu I'm assigning this to you... |
@warengonzaga We can do one of the below
Pros:
Cons:
They will have to change to
Pros:
Pros: cleaner than callback
and ...
|
What do you think is better @JohnDoePBabu? and more standard? |
Hi @warengonzaga, I noticed that when there is no data, eg: no supporters, BMC API sends a 200 response with an error in the response body.
|
Hi @JohnDoePBabu, I would prefer to throw an error message instead of empty array. |
All good closing this issue with merge #18 |
I noticed that currently errors are neither captured, handled, or propagated.
This could be replicated by calling any method with an invalid token (there are many other ways, of course).
if (!error & response.statusCode === 200) { callback(JSON.parse(body)) }
Also, we aren't following the NodeJS error-first-callback practice.
We could modify this by introducing a breaking change and passing the error as the first argument of the callback.
callback(err, JSON.parse(body))
or make it backward compatible by passing error as the second argument. This would be a departure from the usual node JS callback conventions though.
thoughts?
The text was updated successfully, but these errors were encountered: