fix: resolve undefined vars in HorizonError branch and add tests (#256)#310
Open
sanctus-mvp wants to merge 1 commit into
Open
Conversation
|
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.,
|
Contributor
|
Link issue to PR and resolve conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the undefined variable bug in the
HorizonErrorbranch oferrorHandler.js(issue #2) and adds test coverage to prevent regressions.Changes
Bug fix —
src/middleware/errorHandler.jstranslateHorizonErrorwas imported but never called, leavingcodeandhumanMessageas undefined references that threw aReferenceErrorat runtimeconst code = resultCodeandconst humanMessage = translateHorizonError(resultCode)to resolve both variables before they are spread into the responseTests —
tests/errorHandler.test.jsHorizonErrorbranchsuccess: false,error.type === "HorizonError", presence oftitleanddetailtx_bad_seq→ 409,op_no_destination→ 404)not.toThrow()assertion confirming noReferenceErrormessagefor recognised codes, absentmessagefor unrecognised onesOther
package.json(node-cacheversion)Test results
All 13 tests pass. Coverage for
errorHandler.js: 90% statements / 89.65% lines / 100% functions — above the 80% threshold required by #256.