0.1.2 • Published 2 years ago

@hikaru-fi/sc-errors v0.1.2

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
2 years ago

Smart contract errors description

What it does

This package provides human-readable error description for errors received as a result of interaction with Hikaru smart-contracts

How to use

Import index.js file and pass received error:

const { getErrorDescription } = require("hikaru-sc-errors");
...
function handleError(errorMsg) {
    ...
    const errorDescription = getErrorDescription(errorMsg);
    ...
}

You can find example in test file

Function parameters and return values

Function has only one String argument - error message in format HIKARU#123

Function returns ErrorDescription defined as:

/**
 * @typedef ErrorDescription
 * @property {Boolean} knownError
 * @property {String} description
 */

Where:

  • knownError: true if error has correct format and is present in known errors
  • description: error description if knownError === true, otherwise - original error message

Misc

You can find full list of error descriptions here: file with error descriptions