You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend ARCH-002 to enforce centralized logging in helper and engine
files. The new `use-log-helpers` rule flags direct console.log/warn/info
calls, requiring logInfo/logWarn/logDebug from helpers/log.ts instead.
Command files are exempt (I/O layer), along with log.ts (canonical
implementation), reporter.ts (check output system), and login-flow.ts
(interactive device flow UI).
Copy file name to clipboardExpand all lines: .archgate/adrs/ARCH-002-error-handling.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,7 @@ Use three exit codes with clear semantics:
54
54
- Don't catch and swallow unexpected errors — let them propagate
55
55
- Don't show stack traces for user errors
56
56
- Don't use `console.error()` directly — use `logError()` for consistent formatting
57
+
- Don't use `console.log()` or `console.warn()` directly in helper or engine files — use `logInfo()` or `logWarn()` (command files are the I/O layer and may use console directly)
57
58
- Don't exit with code 0 when an operation fails
58
59
- Don't use exit codes other than 0, 1, or 2
59
60
@@ -122,7 +123,7 @@ try {
122
123
### Risks
123
124
124
125
-**Swallowed errors in async code** — Async functions that catch errors without re-throwing can silently fail. Unhandled promise rejections in Bun terminate the process with a non-zero exit code, which provides a safety net, but the error message may be unclear.
125
-
-**Mitigation:** The `logError()`convention makes explicit error handling visible in code review. The `use-log-error`automated rule flags direct `console.error()` usage, nudging developers toward the standard pattern.
126
+
-**Mitigation:** The log helper convention makes explicit error handling visible in code review. The `use-log-error` rule flags direct `console.error()` usage, and the `use-log-helpers` rule flags direct `console.log()`/`console.warn()` in helper and engine files, nudging developers toward the standard pattern.
126
127
-**Exit code 2 masking real issues** — If an unexpected error occurs in a rule file, the CLI exits with code 2 ("internal error") rather than code 1 ("violations"). This could confuse CI systems that only check for non-zero exit.
127
128
-**Mitigation:** The check engine wraps rule execution with timeout and error boundaries, reporting rule errors separately from violations. The `--verbose` flag shows which rules errored.
128
129
@@ -131,6 +132,7 @@ try {
131
132
### Automated Enforcement
132
133
133
134
-**Archgate rule**`ARCH-002/use-log-error`: Scans all source files (excluding `helpers/log.ts` and test files) for `console.error()` usage and flags violations. Severity: `error`.
135
+
-**Archgate rule**`ARCH-002/use-log-helpers`: Scans helper and engine files for direct `console.log()`, `console.warn()`, or `console.info()` usage. Excludes `helpers/log.ts` (canonical implementation), `engine/reporter.ts` (check output system), `helpers/login-flow.ts` (interactive device flow UI), and test files. Command files are exempt since they are the I/O layer. Severity: `error`.
134
136
-**Archgate rule**`ARCH-002/exit-code-convention`: Scans all source files for `process.exit()` calls and verifies the exit code is 0, 1, or 2. Severity: `error`.
0 commit comments