I am using a Node.JS library called GitNode. I don't think it's important but basically it's an API for git commands in Node.JS.
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.
This is the entirety of my code:
var Git = require("nodegit");
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 a lot of catch statements in the hopes of finding my error. But I can't seem to output anything. Neither the phrase "Bad_error" or "Bad_catch" output.
I know the code is broken and that createBranch isn't working. I tested some code that was supposed to run after I called repository.createBranch
, but it never runs where as anything before createBranch is called will run. This indicates that CreateBranch is the problem.
So why are my errors not being caught?
Edit
I've fixed the code and it outputs the error (see answer below), but I'm still wondering why my other exceptions/error statements failed to work.