{"record":{"id":"db76c17ffaca4953","repo":"pcottle/learnGitBranching","slug":"dynamic-branch-listing","errorCode":null,"errorMessage":"<dynamic branch listing>","messagePattern":"<dynamic branch listing>","errorType":"validation","errorClass":"CommandResult","httpStatus":null,"severity":"info","filePath":"src/js/git/index.js","lineNumber":853,"sourceCode":"};\n\nGitEngine.prototype.printBranchesWithout = function(without) {\n  var commitToBranches = this.getUpstreamBranchSet();\n  var commitID = this.getCommitFromRef(without).get('id');\n\n  var toPrint = commitToBranches[commitID].map(function (branchJSON) {\n    branchJSON.selected = this.HEAD.get('target').get('id') == branchJSON.id;\n    return branchJSON;\n  }, this);\n  this.printBranches(toPrint);\n};\n\nGitEngine.prototype.printBranches = function(branches) {\n  var result = '';\n  branches.forEach(branch => {\n    result += (branch.selected ? '* ' : '') + this.resolveName(branch.id).split('\"')[1] + '\\n';\n  });\n  throw new CommandResult({\n    msg: result\n  });\n};\n\nGitEngine.prototype.printTags = function(tags) {\n  var result = '';\n  tags.forEach(function (tag) {\n    result += tag.id + '\\n';\n  });\n  throw new CommandResult({\n    msg: result\n  });\n};\n\nGitEngine.prototype.printRemotes = function(options) {\n  var result = '';\n  if (options.verbose) {\n    result += 'origin (fetch)\\n';","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/index.js#L835-L871","documentation":"Not a failure: printBranches formats the branch listing (selected branch prefixed with '* ', display names unquoted via split('\"')[1]) and delivers it by throwing a CommandResult, the app's control-flow mechanism for command output.","triggerScenarios":"Any `git branch` (or branch listing variant) executed successfully; the thrown CommandResult is caught by the command pipeline and displayed.","commonSituations":"Not applicable as an error; only relevant when writing code that calls GitEngine directly and doesn't expect the throw-for-output pattern.","solutions":["Catch CommandResult separately from GitError when driving GitEngine programmatically","Use CommandResult.prototype instanceof checks to distinguish output from failure","Rely on the built-in command pipeline rather than calling printBranches directly"],"exampleFix":"// before\nengine.printBranches(branches); // throws\n// after\ntry { engine.printBranches(branches); }\ncatch (e) { if (e instanceof CommandResult) display(e.msg); else throw e; }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isCommandResult(e){ return e instanceof CommandResult; }","tryCatchPattern":"try { engine.printBranches(branches); } catch (e) { if (e instanceof CommandResult) { show(e.msg); } else { throw e; } }","preventionTips":["Never call print* methods without a CommandResult catch","Prefer the command pipeline for display"],"tags":["git","branch","command-output","control-flow"],"backgroundTag":"result-as-exception-pattern","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}