diff --git a/src/utils/horizonErrors.js b/src/utils/horizonErrors.js index 00cfb48..9506063 100644 --- a/src/utils/horizonErrors.js +++ b/src/utils/horizonErrors.js @@ -1,5 +1,6 @@ /** * Plain-English translations for common Horizon error codes. + * @type {Object.} */ 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.", @@ -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;