Skip to content

fix: resolve undefined vars in HorizonError branch and add tests (#256)#310

Open
sanctus-mvp wants to merge 1 commit into
stellarkit-lab-devtools:mainfrom
sanctus-mvp:fix/256-horizon-error-branch-tests
Open

fix: resolve undefined vars in HorizonError branch and add tests (#256)#310
sanctus-mvp wants to merge 1 commit into
stellarkit-lab-devtools:mainfrom
sanctus-mvp:fix/256-horizon-error-branch-tests

Conversation

@sanctus-mvp

Copy link
Copy Markdown
Contributor

Summary

Fixes the undefined variable bug in the HorizonError branch of errorHandler.js (issue #2) and adds test coverage to prevent regressions.

Changes

Bug fix — src/middleware/errorHandler.js

  • translateHorizonError was imported but never called, leaving code and humanMessage as undefined references that threw a ReferenceError at runtime
  • Added const code = resultCode and const humanMessage = translateHorizonError(resultCode) to resolve both variables before they are spread into the response

Tests — tests/errorHandler.test.js

  • 13 tests covering the full HorizonError branch
  • Asserts success: false, error.type === "HorizonError", presence of title and detail
  • Verifies mapped HTTP status codes (tx_bad_seq → 409, op_no_destination → 404)
  • Explicit not.toThrow() assertion confirming no ReferenceError
  • Covers translated message for recognised codes, absent message for unrecognised ones

Other

  • Resolved a git merge conflict marker in package.json (node-cache version)

Test results

All 13 tests pass. Coverage for errorHandler.js: 90% statements / 89.65% lines / 100% functions — above the 80% threshold required by #256.

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

Hey @sanctus-mvp! 👋 It looks like this PR isn't linked to any issue.

If this PR is for one of the issues assigned to you as part of a Wave, please link it to ensure your contribution is tracked properly. You can do this by adding a keyword to the PR description (e.g., Closes #123), or by clicking a button below:

Issue Title
#256 Add tests for the HorizonError branch in errorHandler.js Link to this issue

ℹ️ Learn more about linking PRs to issues

@Sulex45

Sulex45 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Link issue to PR and resolve conflicts

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.

2 participants