Skip to content

fix: preserve original error in requestSessionResult#35

Draft
dobby-coder[bot] wants to merge 1 commit into
masterfrom
fix/request-session-result-error-wrapping
Draft

fix: preserve original error in requestSessionResult#35
dobby-coder[bot] wants to merge 1 commit into
masterfrom
fix/request-session-result-error-wrapping

Conversation

@dobby-coder

@dobby-coder dobby-coder Bot commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Fixes #28.

IrmaService.requestSessionResult wrapped caught errors with new Error(e), which coerces the original error to a string — for HTTP/network error objects the message becomes "[object Object]" and the original stack trace is lost. The author had left a // TODO: Fix error handling acknowledging this.

Change

Replace the wrapping with log-and-rethrow, following the issue's suggested fix:

  • Log the failure with session-token context via the existing Winston logger, using the %o splat style already used elsewhere in the codebase (server/src/api/index.ts, server/src/api/vote.ts).
  • Rethrow the original error so it propagates to Express with its message and stack intact.

Also removed the now-unneeded : any annotation on the catch binding and the stale TODO.

Verification

  • The server package has no test suite (npm test is a no-op placeholder), so verification is via type-checking: tsc --noEmit reports 0 errors.
  • Checked the only caller (server/src/api/result.ts) — it does not depend on the wrapped error, so behaviour is unchanged apart from improved error fidelity.

🤖 Generated with Claude Code

Wrapping the caught error with new Error(e) coerced it to the string
"[object Object]" and discarded the original stack trace. Log the
failure with context and rethrow the original error instead.

Fixes #28

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

maintenance: requestSessionResult error wrapping discards stack trace and original error

0 participants