Skip to content

feat(trpc): standard error formatting for high-throughput indexer API - #618

Merged
github-actions[bot] merged 4 commits into
Sahara-Pay:mainfrom
samkay-ops:main
Aug 23, 2026
Merged

feat(trpc): standard error formatting for high-throughput indexer API#618
github-actions[bot] merged 4 commits into
Sahara-Pay:mainfrom
samkay-ops:main

Conversation

@samkay-ops

Copy link
Copy Markdown
Contributor

Summary

Implements standard tRPC error formatting for the Fastify indexer API (#598).

Previously HTTP/batch handlers returned ad-hoc { error, message } payloads and often leaked internal Error.message values. Procedures also threw plain Errors.

Changes

  • Add errors.ts with toTRPCError, formatTRPCErrorShape, and helpers
  • Enable errorFormatter on the shared initTRPC instance (optional zodError)
  • Normalize batch + single HTTP catch paths to tRPC-shaped errors + correct HTTP status
  • Throw TRPCError for unknown procedure / unsupported subscription
  • Unit tests for mapping, sanitization, and wire shape

Acceptance criteria

  • Execution stays non-blocking (sync mapping only; no extra I/O on the error path)
  • Edge cases / malformed inputs map to BAD_REQUEST or NOT_FOUND without crashing the process
  • Internal failures return a generic message; details stay in server logs
  • Response shape is consistent for single and batch calls
  • Type-safe TRPCError boundary preserved

Closes #598

@github-actions
github-actions Bot merged commit 8a8a69b into Sahara-Pay:main Aug 23, 2026
1 check passed
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.

Architect tRPC error standard formatting for high-throughput indexer API

1 participant