Skip to content

feat: human-readable Horizon error message translator#225

Merged
Sulex45 merged 2 commits into
stellarkit-lab-devtools:mainfrom
FaithOnuh:fix/horizon-error-translator-202
Jun 7, 2026
Merged

feat: human-readable Horizon error message translator#225
Sulex45 merged 2 commits into
stellarkit-lab-devtools:mainfrom
FaithOnuh:fix/horizon-error-translator-202

Conversation

@FaithOnuh

Copy link
Copy Markdown
Contributor

Summary

Resolves #202

Extends the error handler to translate cryptic Horizon result codes (e.g. tx_bad_seq, op_no_trust) into plain-English messages automatically.

Changes

  • src/utils/horizonErrors.js (new): Translator with 17 common Horizon error codes mapped to plain-English descriptions covering transaction errors (tx_*) and operation errors (op_*).
  • src/middleware/errorHandler.js: Updated HorizonError handler to extract result_codes from Horizon extras, translate to human-readable message, and include the original code field in the response.
  • tests/api.test.js: Added 12 new tests verifying all covered codes, null returns for unknown codes, and integration through the error handler. Fixed a pre-existing extra closing bracket.

Error Response Shape

{
  "success": false,
  "error": {
    "type": "HorizonError",
    "title": "Transaction Failed",
    "detail": "...",
    "status": 400,
    "extras": { "result_codes": { "transaction": "tx_bad_seq" } },
    "code": "tx_bad_seq",
    "message": "Transaction sequence number does not match the account's current sequence. Reload the account and rebuild the transaction."
  }
}

Covered Error Codes (17)

tx_bad_seq, tx_insufficient_fee, tx_bad_auth, tx_no_source_account, tx_bad_auth_extra, tx_internal_error, tx_not_supported, tx_fee_bump_inner_failed, op_no_destination, op_no_trust, op_line_full, op_underfunded, op_low_reserve, op_bad_auth, op_no_account, op_not_authorized, op_malformed

Tests

85 passed, 2 skipped (pre-existing skips)

…-devtools#202)

- Add src/utils/horizonErrors.js with 17 error code translations
- Update errorHandler to extract result_codes and translate to plain English
- Include original code field alongside human-readable message in response
- Add tests verifying all covered codes, null for unknowns, and integration
- Fix pre-existing extra closing bracket in api.test.js
@drips-wave

drips-wave Bot commented Jun 2, 2026

Copy link
Copy Markdown

@FaithOnuh 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

@Sulex45

Sulex45 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

resolve Conflict in test/api.test

@Sulex45 Sulex45 merged commit 0eaa63c into stellarkit-lab-devtools:main Jun 7, 2026
1 of 3 checks 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.

Human-Readable Horizon Error Message Translator

2 participants