errors.mjs
19 lines 660 B
Raw
sha256:c2dbf04d56308f3bbf2d06e6d2eb022b8948b1e827195fe525a44e5e18d5f9c0 feat(auth): Phase B Connect cloud agent (RFC 8628) + Hermes… Human minor ⚠ breaking 11 days ago
1 /**
2 * CLI error handling: exit 1 (usage) / 2 (runtime), optional JSON error object. SPEC §4.2, §4.3.
3 */
4
5 /**
6 * Print error and exit. With useJson, writes { "error": message, "code": code } to stderr and exits.
7 * @param {string} message
8 * @param {1|2} code - 1 = usage, 2 = runtime
9 * @param {boolean} useJson - If true, output JSON error object to stderr
10 */
11 export function exitWithError(message, code = 1, useJson = false) {
12 if (useJson) {
13 const err = { error: message, code: code === 1 ? 'USAGE_ERROR' : 'RUNTIME_ERROR' };
14 process.stderr.write(JSON.stringify(err) + '\n');
15 } else {
16 console.error(message);
17 }
18 process.exit(code);
19 }
File History 1 commit
sha256:93bcf8f9bd56d8c5b9339f4ec73b9ebd66571398d56262d38eedc2cfa9db9882 fix(test): align Band B landing assertion with desktop MCP … Human 11 days ago