Monday, 22 May 2017

Nodegit: Why can't I get any error output

I have a piece of code whose purpose is to create a new branch in an existing repository. After running the code, I know it's not creating a repository, and I also know it's not working correctly.

var getMostRecentCommit = function(repository) {
  return repository.getBranchCommit("master");
};

var makeBranch = function(respository) {
  console.log("in here1")
  repository.createBranch("tester", getMostRecentCommit(repository)).then(
      function(reference) {
           console.log("good")},               // if it works
      function(reasonForFailure) {
           console.log("bad_error")})          // createBranch has error case
      .catch(function(reasonForFailure) {
           console.log("bad_catch")});         // if the error function fails, I also have a catch statement
};


Git.Repository.open("../test_repo")
  .then(makeBranch);

I've placed both a catch statement and an error handling function. HOWEVER, I can't seem to output any errors. Neither Bad_error or Bad_catch output. Likewise, I have some code that is supposed to run after repository.createBranch, but doesn't. Which indicates that my code stops running when it reaches createBranch.

Why are my errors not being caught?



via Wild dog

No comments:

Post a Comment