{"record":{"id":"fc2182e11a8a22ec","repo":"pcottle/learnGitBranching","slug":"this-getstatusmsg","errorCode":null,"errorMessage":"this.getStatusMsg()","messagePattern":"this\\.getStatusMsg\\(\\)","errorType":"exception","errorClass":"CommandResult","httpStatus":null,"severity":"info","filePath":"src/js/git/index.js","lineNumber":3093,"sourceCode":"    unstaged.forEach(function(path) {\n      lines.push(TAB + 'modified:   ' + path);\n    });\n  }\n\n  if (!staged.length && !unstaged.length) {\n    lines.push(intl.str('git-status-clean'));\n  } else if (!staged.length) {\n    // only unstaged changes -- git prints this reminder at the end\n    lines.push('');\n    lines.push('no changes added to commit (use \"git add\" and/or \"git commit -a\")');\n  }\n\n  return lines.join('\\n') + '\\n';\n};\n\nGitEngine.prototype.status = function() {\n  if (this.changesModelEngaged) {\n    throw new CommandResult({\n      msg: this.getStatusMsg()\n    });\n  }\n\n  // classic graph-only levels: keep the original playful output untouched\n  var lines = [];\n  if (this.getDetachedHead()) {\n    lines.push(intl.str('git-status-detached'));\n  } else {\n    var branchName = this.resolveNameNoPrefix('HEAD');\n    lines.push(intl.str('git-status-onbranch', {branch: branchName}));\n  }\n  lines.push('Changes to be committed:');\n  lines.push('');\n  lines.push(TAB + 'modified: cal/OskiCostume.stl');\n  lines.push('');\n  lines.push(intl.str('git-status-readytocommit'));\n","sourceCodeStart":3075,"sourceCodeEnd":3111,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/index.js#L3075-L3111","documentation":"Not a failure: when the working-directory/staging simulation is active (changesModelEngaged), git status returns its report by throwing a CommandResult containing this.getStatusMsg() — the per-path status lines (staged/unstaged files).","triggerScenarios":"Running git status in a level that engages the changes model (working directory + index simulation).","commonSituations":"Levels/exercises with file staging; expected informational output.","solutions":["No fix needed","Catch CommandResult and render/capture msg"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { engine.status(); } catch (e) { if (e instanceof CommandResult) { display(e.msg); } else throw e; }","preventionTips":["Catch CommandResult for read-only command output"],"tags":["git","status","command-result","staging"],"backgroundTag":"command-result-output","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}