Skip to content

Expose JavaScript function name in a rejected promise#1393

Merged
implausible merged 1 commit intonodegit:masterfrom
rcjsuen:errorFunction
Nov 28, 2017
Merged

Expose JavaScript function name in a rejected promise#1393
implausible merged 1 commit intonodegit:masterfrom
rcjsuen:errorFunction

Conversation

@rcjsuen
Copy link
Copy Markdown
Member

@rcjsuen rcjsuen commented Oct 28, 2017

I've modified the async_function.cc template to include both the names of the JavaScript class and function in the error thrown in a rejected promise. This should hopefully make debugging NodeGit a lot easier when there's a long promise chain.

When an error happens in libgit2, NodeGit will wrap the and expose
the error code and message to be consumed via the JavaScript API.
However, this information is often insufficient given the
asynchronous nature of NodeGit and it may at times be unclear as to
which JavaScript function caused the error on the libgit2 side. By
exposing an 'errorFunction' property string that includes the name of
the JavaScript function in the error, debugging should now be a lot
easier as clients will now be able to quickly identify which
JavaScript function in a long promise chain was the source of an
error.

Signed-off-by: Remy Suen <remy.suen@gmail.com>
@cjhoward92
Copy link
Copy Markdown
Collaborator

I like this! Nice work. @implausible what do you think? Not a perfect solution but helpful none-the-less.

@implausible
Copy link
Copy Markdown
Member

Radical @rcjsuen!

@implausible implausible merged commit 88e3ec6 into nodegit:master Nov 28, 2017
@rcjsuen rcjsuen deleted the errorFunction branch December 20, 2017 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants