Skip to content

Feat/381 centralize api error handling - #545

Open
Jessepriase wants to merge 4 commits into
Core-Foundry:mainfrom
Jessepriase:feat/381-centralize-api-error-handling
Open

Feat/381 centralize api error handling#545
Jessepriase wants to merge 4 commits into
Core-Foundry:mainfrom
Jessepriase:feat/381-centralize-api-error-handling

Conversation

@Jessepriase

Copy link
Copy Markdown

closes #381

Jess and others added 4 commits June 26, 2026 22:33
- Remove _nextAddress parameter from useWalletAccountSync callbacks in
  EventExplorerPage and ActivityFeed. Neither caller uses the address
  value. Updates hook signature to () => void to match.
- Replace WALLET_ADDRESS_KEY references in regression tests with the
  inline string 'notify-chain:wallet-address'. The constant was never
  declared in this version of the test file, causing TS2552 in
  tsc --noEmit.
Introduce listener/src/utils/api-error.ts with two exports:

- sendError(res, status, message) — the single place where all error
  responses are serialised. Writes { error: string } with Content-Type
  application/json. All route handlers now call this instead of
  inlining res.writeHead + res.end pairs.

- ApiError — a typed Error subclass that carries an HTTP status code,
  allowing catch blocks to forward errors to sendError without a
  separate status lookup.

Wire sendError into every route handler:
- events-server.ts: 61 inline error responses replaced (400/401/404/
  413/422/500/503). The health endpoint's { status, detail } shape and
  the batch validation { valid, errors } shape are intentionally left
  as-is — they are structured data responses, not error responses.
- archive-api.ts: 5 inline error responses replaced.
- template-routes.ts: 23 inline error responses replaced.

Also fix listener/package.json: duplicate script keys and a missing
comma caused npm install to fail with EJSONPARSE.
@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@Jessepriase Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Centralize API Error Handling

1 participant