Error(w, err) now extracts PlatformCode() from *xerrors.Err and includes "platformCode" in the JSON error body when set; omitted when not set (backwards-compatible)
errorBody updated to accept platformCode as an explicit parameter
Upgraded code.nochebuena.dev/go/xerrors dependency to v0.10.0
Two new tests: TestError_PlatformCode_IncludedWhenSet, TestError_PlatformCode_OmittedWhenNotSet
Error response shape
With platform code:
{"code":"NOT_FOUND","platformCode":"EMPLOYEE_NOT_FOUND","message":"employee not found"}
Without platform code (unchanged from v0.9.0):
{"code":"NOT_FOUND","message":"employee not found"}
Motivation
Frontend teams need a stable, transport-agnostic identifier for domain errors to drive i18n message lookup. Code is transport-bounded (ErrNotFound → 404); platformCode is open-ended and domain-specific. The transport layer passes it through transparently — no mapping logic added here.
## Summary
- `Error(w, err)` now extracts `PlatformCode()` from `*xerrors.Err` and includes `"platformCode"` in the JSON error body when set; omitted when not set (backwards-compatible)
- `errorBody` updated to accept `platformCode` as an explicit parameter
- Upgraded `code.nochebuena.dev/go/xerrors` dependency to `v0.10.0`
- Two new tests: `TestError_PlatformCode_IncludedWhenSet`, `TestError_PlatformCode_OmittedWhenNotSet`
## Error response shape
With platform code:
```json
{
"code": "NOT_FOUND",
"platformCode": "EMPLOYEE_NOT_FOUND",
"message": "employee not found"
}
```
Without platform code (unchanged from v0.9.0):
```json
{
"code": "NOT_FOUND",
"message": "employee not found"
}
```
## Motivation
Frontend teams need a stable, transport-agnostic identifier for domain errors to drive i18n message lookup. `Code` is transport-bounded (`ErrNotFound` → 404); `platformCode` is open-ended and domain-specific. The transport layer passes it through transparently — no mapping logic added here.
## Test plan
- [x] `go test ./...` passes
- [x] `TestError_PlatformCode_IncludedWhenSet` — 404 response contains `platformCode: "EMPLOYEE_NOT_FOUND"`
- [x] `TestError_PlatformCode_OmittedWhenNotSet` — response body has no `platformCode` key
- [x] All existing tests pass unchanged
🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Error(w, err) now extracts PlatformCode() from *xerrors.Err and
includes "platformCode" in the JSON body when set; omitted otherwise
- errorBody updated to accept platformCode as an explicit parameter
- Upgraded code.nochebuena.dev/go/xerrors dependency to v0.10.0
- Added two new tests: platformCode included when set, omitted when absent
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rene Nochebuena
approved these changes 2026-03-25 16:57:45 -06:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Error(w, err)now extractsPlatformCode()from*xerrors.Errand includes"platformCode"in the JSON error body when set; omitted when not set (backwards-compatible)errorBodyupdated to acceptplatformCodeas an explicit parametercode.nochebuena.dev/go/xerrorsdependency tov0.10.0TestError_PlatformCode_IncludedWhenSet,TestError_PlatformCode_OmittedWhenNotSetError response shape
With platform code:
Without platform code (unchanged from v0.9.0):
Motivation
Frontend teams need a stable, transport-agnostic identifier for domain errors to drive i18n message lookup.
Codeis transport-bounded (ErrNotFound→ 404);platformCodeis open-ended and domain-specific. The transport layer passes it through transparently — no mapping logic added here.Test plan
go test ./...passesTestError_PlatformCode_IncludedWhenSet— 404 response containsplatformCode: "EMPLOYEE_NOT_FOUND"TestError_PlatformCode_OmittedWhenNotSet— response body has noplatformCodekey🤖 Generated with Claude Code
LGTM