GitNode라는 Node.JS 라이브러리를 사용하고 있습니다. 중요하지는 않지만 기본적으로 Node.JS의 git 명령 용 API입니다.Node.JS에서 오류 또는 예외를 출력하지 못합니다.
기존 저장소에 새 분기를 만드는 것이 목적 인 코드 조각이 있습니다. 코드를 실행 한 후에 저장소가 생성되지 않는다는 것을 알고 있으며 올바르게 작동하지 않는다는 것도 알고 있습니다.
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);
내 오류를 찾는 희망 catch 문을 많이 배치했습니다
이
내 코드의 전체입니다. 그러나 나는 아무것도 출력하지 않는 것 같습니다. 문구 "Bad_error"또는 "Bad_catch"가 출력되지 않습니다.코드가 손상되어 createBranch가 작동하지 않는다는 것을 알고 있습니다. repository.createBranch
을 호출 한 후 실행해야하는 코드를 테스트했지만, createBranch가 호출되기 전에 아무 것도 실행되지 않습니다. 이는 CreateBranch가 문제임을 나타냅니다.
왜 내 오류가 발견되지 않습니까?
편집
내가 코드를 수정했습니다과 오류를 출력 (아래 답변을 참조)하지만 내 다른 예외/오류 문이 작동하는 데 실패 난 아직도 왜 궁금하네요.