FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Expose libgit2 error code to clients when a promise fails by rcjsuen · Pull Request #1209 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cc  (4) .js  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,15 @@ void GitPatch::ConvenientFromDiffWorker::HandleOKCallback() {
}

if (baton->error) {
Local<v8::Object> err;
if (baton->error->message) {
err = Nan::Error(baton->error->message)->ToObject();
} else {
err = Nan::Error("Method convenientFromDiff has thrown an error.")->ToObject();
}
err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code));
Local<v8::Value> argv[1] = {
Nan::Error(baton->error->message)
err
};
callback->Call(1, argv);
if (baton->error->message)
Expand Down
9 changes: 8 additions & 1 deletion generate/templates/manual/revwalk/fast_walk.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,15 @@ void GitRevwalk::FastWalkWorker::HandleOKCallback()
{
if (baton->error)
{
Local<v8::Object> err;
if (baton->error->message) {
err = Nan::Error(baton->error->message)->ToObject();
} else {
err = Nan::Error("Method fastWalk has thrown an error.")->ToObject();
}
err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code));
Local<v8::Value> argv[1] = {
Nan::Error(baton->error->message)
err
};
callback->Call(1, argv);
if (baton->error->message)
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,15 @@ void GitRevwalk::FileHistoryWalkWorker::HandleOKCallback()
}

if (baton->error) {
Local<v8::Object> err;
if (baton->error->message) {
err = Nan::Error(baton->error->message)->ToObject();
} else {
err = Nan::Error("Method fileHistoryWalk has thrown an error.")->ToObject();
}
err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code));
Local<v8::Value> argv[1] = {
Nan::Error(baton->error->message)
err
};
callback->Call(1, argv);
if (baton->error->message)
Expand Down
9 changes: 8 additions & 1 deletion generate/templates/partials/async_function.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,15 @@ void {{ cppClassName }}::{{ cppFunctionName }}Worker::HandleOKCallback() {
callback->Call(2, argv);
} else {
if (baton->error) {
v8::Local<v8::Object> err;
if (baton->error->message) {
err = Nan::Error(baton->error->message)->ToObject();
} else {
err = Nan::Error("Method {{ jsFunctionName }} has thrown an error.")->ToObject();
}
err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code));
v8::Local<v8::Value> argv[1] = {
Nan::Error(baton->error->message)
err
};
callback->Call(1, argv);
if (baton->error->message)
Expand Down
22 changes: 22 additions & 0 deletions test/tests/merge.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1298,4 +1298,26 @@ describe("Merge", function() {
assert.ok(repository.isDefaultState());
});
});

it("can retrieve error code on if common merge base not found", function() {
var repo;
return NodeGit.Repository.open(local("../repos/workdir"))
.then(function(r) {
repo = r;
return repo.getCommit("4bd806114ce26503c103c85dcc985021951bbc18");
})
.then(function(commit) {
return commit.getParents(commit.parentcount());
})
.then(function(parents) {
return NodeGit.Merge.base(repo, parents[0], parents[1])
.then(function() {
return Promise.reject(new Error(
"should not be able to retrieve common merge base"));
}, function(err) {
assert.equal("no merge base found", err.message);
assert.equal(NodeGit.Error.CODE.ENOTFOUND, err.errno);
});
});
});
});

Back | FazBrowse Home | New Git URL