Expand description
Single-line failure diagnostic for every Gitway binary.
When a Gitway binary runs and fails in human (non-JSON) mode, one
emit or emit_for call writes a logfmt-style record to stderr:
gitway diag ts=2026-04-22T18:43:11Z pid=12345 code=4 reason=PERMISSION_DENIED argv=["gitway", "git@github.com", "git-upload-pack", "'org/repo.git'"]The point is to turn silent exit 128 failures — the opaque code git
reports when core.sshCommand fails — into a single grep-able line
that carries enough context to triage: ISO 8601 timestamp, PID, argv,
exit code, and a short error reason.
JSON mode already carries timestamp and command in its structured
{"error": {...}} blob, so callers should skip this helper on that
path. Stdout is always left untouched (SFRS Rule 1) — the diagnostic
writes exclusively to stderr.
Functions§
- emit
- Emits the single-line diagnostic record with an explicit exit code and
a reason string. Use this from the shim binaries (
gitway-keygen,gitway-add) where the reason codes are selected from a local static table; useemit_forwhen aGitwayErroris already in hand. - emit_
for - Emits the diagnostic record for a
GitwayError, reusing the error’s mapped exit code and string error class.