{"record":{"id":"61dd25660ec4a351","repo":"abhigyanpatwari/GitNexus","slug":"group-groupname-not-found","errorCode":null,"errorMessage":"Group \"${groupName}\" not found","messagePattern":"Group \"(.+?)\" not found","errorType":"exception","errorClass":"GroupNotFoundError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/group/config-parser.ts","lineNumber":130,"sourceCode":"}\n\nexport class GroupNotFoundError extends Error {\n  constructor(public readonly groupName: string) {\n    super(`Group \"${groupName}\" not found`);\n    this.name = 'GroupNotFoundError';\n  }\n}\n\nexport async function loadGroupConfig(groupDir: string): Promise<GroupConfig> {\n  const fsp = await import('node:fs/promises');\n  const path = await import('node:path');\n  const yamlPath = path.join(groupDir, 'group.yaml');\n  let content: string;\n  try {\n    content = await fsp.readFile(yamlPath, 'utf-8');\n  } catch (err) {\n    if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n      throw new GroupNotFoundError(path.basename(groupDir));\n    }\n    throw err;\n  }\n  return parseGroupConfig(content);\n}\n","sourceCodeStart":112,"sourceCodeEnd":136,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/group/config-parser.ts#L112-L136","documentation":"Thrown as GroupNotFoundError by loadGroupConfig when reading <groupDir>/group.yaml fails with ENOENT — the group directory exists in the path but has no group.yaml manifest. This is a distinct, named error class (not a generic Error) so callers can branch on it with instanceof. The constructor takes the group's basename for the message.","triggerScenarios":"Calling loadGroupConfig on a directory that doesn't contain group.yaml — either the group was never created, was partially deleted, or the wrong path was passed.","commonSituations":"Typo in the group name passed to a group command; the group directory was created manually without using createGroupDir (so no template was written); a cleanup removed group.yaml but left the directory; pointing at the wrong GITNEXUS_HOME.","solutions":["List groups with the group-list CLI / listGroups() to confirm the group name exists.","If the group should exist, re-create it (createGroupDir writes the manifest template, then edit it).","Catch GroupNotFoundError by name (instanceof GroupNotFoundError) to give a clean 'unknown group' UX rather than a generic error.","Verify GITNEXUS_HOME points at the directory where the group was actually created."],"exampleFix":"// before — generic catch masks the not-found case\ntry { await loadGroupConfig(dir); }\ncatch (e) { console.error('failed', e.message); }\n\n// after — branch on the named error class\nimport { GroupNotFoundError } from './config-parser.js';\ntry { await loadGroupConfig(dir); }\ncatch (e) {\n  if (e instanceof GroupNotFoundError) console.error(`No such group: ${e.groupName}`);\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":"import * as fs from 'node:fs';\n// pre-check existence before calling loadGroupConfig\nfunction groupManifestExists(groupDir: string): boolean {\n  try { return fs.statSync(`${groupDir}/group.yaml`).isFile(); }\n  catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"import { GroupNotFoundError, loadGroupConfig } from './config-parser.js';\ntry {\n  const cfg = await loadGroupConfig(groupDir);\n} catch (err) {\n  if (err instanceof GroupNotFoundError) {\n    // clean not-found UX — suggest listing groups\n    console.error(`No such group: ${err.groupName}. Run group-list to see available groups.`);\n    return;\n  }\n  throw err; // rethrow parse errors etc.\n}","preventionTips":["Always branch on `instanceof GroupNotFoundError` rather than string-matching the message.","Pre-check groupManifestExists if you want to avoid the throw entirely.","Confirm GITNEXUS_HOME is set to the directory where the group was created."],"tags":["group-config","not-found","filesystem","named-error","config-parser"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}