moul / node-gitlab

DEPRECATED, see https://github.com/node-gitlab/node-gitlab
https://npmjs.org/package/gitlab
Other
470 stars 140 forks source link

How do I get errors passed back to my callbacks? #123

Closed fuhbar closed 5 years ago

fuhbar commented 8 years ago

It seems that a potential error returned by the remote HTTP endpoint is never returned to the caller.

The wrapper around slumber return errors only if the argument length (arity) of the callback is as expected: https://github.com/node-gitlab/node-gitlab/blob/develop/src/ApiBaseHTTP.coffee#L41-L47

But the callback evaluated there is not the one supplied by the user. Random samples of some central models support this thesis and show that only a wrapper is ever seen by the lines of code quoted above: https://github.com/node-gitlab/node-gitlab/blob/develop/src/Models/Projects.coffee#L42 (...) https://github.com/node-gitlab/node-gitlab/blob/develop/src/Models/Groups.coffee#L38 (...)

My question is therefore, how do I get notified in case of errors. I need to ensure that my operations placed at the remote gitlab instance were carry out succesfully.

fuhbar commented 8 years ago

This somehow relates to issue #76 - at least the recent comments.

Nevertheless I opened a new issue because I am interested in the possibility of error handling at all and not in the discussion of API design mentioned in the quoted issue.

dave-irvine commented 8 years ago

Ah. Right. I see the problem. That's a pretty big issue.

@moul suggest we find and replace in the codebase.

Search: , (data) => fn data if fn and , (data) -> fn data if fn, then replace with fn

Then change https://github.com/node-gitlab/node-gitlab/blob/develop/src/ApiBaseHTTP.coffee#L41 to handle cases when fn is null.

What do you think?

brendan-hurley commented 7 years ago

Is this being looked at all anymore?

slyadams commented 6 years ago

I thikn I'm having the same problem, it doesn't matter how many arguments I pass to my callback I only ever get the result in the first argument, so I'm unable to catch any errors.

brendan-hurley commented 6 years ago

I ended up just making calls directly to API with a simple little wrapper

slyadams commented 6 years ago

Yeah, I might do the same, I'm also not sure when api v3 is going to be deprecated by gitlab.