Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/utils/horizonErrors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Plain-English translations for common Horizon error codes.
* @type {Object.<string, string>}
*/
const HORIZON_ERROR_MESSAGES = {
tx_bad_seq: "Transaction sequence number does not match the account's current sequence. Reload the account and rebuild the transaction.",
Expand All @@ -24,8 +25,17 @@ const HORIZON_ERROR_MESSAGES = {
/**
* Translate a Horizon error code to a plain-English message.
*
* @param {string} code - Horizon result code (e.g. "tx_bad_seq")
* @returns {string|null} Human-readable message, or null if not found
* @param {string} code - Horizon result code (e.g. "tx_bad_seq" or "op_no_destination")
* @returns {string|null} Human-readable message, or null if the error code is not found
* @example
* // Returns a known error message
* translateHorizonError("tx_bad_seq");
* // Returns: "Transaction sequence number does not match the account's current sequence. Reload the account and rebuild the transaction."
*
* @example
* // Returns null for an unknown error code
* translateHorizonError("tx_unknown_code");
* // Returns: null
*/
function translateHorizonError(code) {
return HORIZON_ERROR_MESSAGES[code] || null;
Expand Down
Loading