0.84.0 • Published 21 hours ago

@fuel-ts/errors v0.84.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
21 hours ago

@fuel-ts/errors

@fuel-ts/errors is a sub-module for interacting with Fuel.

This package contains core utilities regarding throwing errors internally inside of the fuels-ts SDK.

Table of contents

Documentation

See Fuels-ts Documentation

Usage

Installation

yarn add @fuel-ts/errors
# or
npm add @fuel-ts/errors

Internal usage

import { FuelError, ErrorCodes } from "@fuel-ts/error";

export function singleImport() {
  throw new FuelError(FuelError.CODES.INVALID_URL, "Invalid URL");
}

export function multipleImports() {
  throw new FuelError(ErrorCodes.INVALID_URL, "Invalid URL");
}

External usage

import { FuelError, Provider } from "fuels";

type Locale = "PT_BR" | "BS_BA";

const currentLocale: Locale = "PT_BR";

const i18nDict = {
  PT_BR: {
    [FuelError.CODES.INVALID_URL]: "Endereço inválido",
    [FuelError.CODES.INSUFFICIENT_BALANCE]: "Saldo insuficiente",
  },
  BS_BA: {
    [FuelError.CODES.INVALID_URL]: "Nevažeća adresa",
    [FuelError.CODES.INSUFFICIENT_BALANCE]: "Nedovoljan balans",
  },
};

function translateError(e: unknown) {
  const { code } = FuelError.parse(e);
  return i18nDict[currentLocale][code];
}

(function main() {
  try {
    const p = new Provider("0004:tƨoʜlɒɔol//:qttʜ");
    console.log(p);
  } catch (e) {
    const prettyError = translateError(e);
    console.log({ prettyError });
  }
})();

Contributing

In order to contribute to @fuel-ts/errors, please see the main fuels-ts monorepo.

Changelog

The @fuel-ts/errors changelog can be found at CHANGELOG.

License

The primary license for @fuel-ts/errors is Apache 2.0, see LICENSE.

0.84.0

6 days ago

0.83.0

14 days ago

0.82.0

15 days ago

0.81.0

22 days ago

0.80.0

24 days ago

0.76.9

1 month ago

0.76.11

1 month ago

0.76.10

1 month ago

0.76.12

1 month ago

0.76.8

1 month ago

0.76.7

1 month ago

0.79.0

1 month ago

0.76.5

1 month ago

0.76.4

1 month ago

0.78.0

2 months ago

0.76.3

2 months ago

0.76.2

2 months ago

0.76.1

2 months ago

0.77.0

2 months ago

0.76.0

2 months ago

0.75.0

2 months ago

0.74.0

3 months ago

0.73.0

3 months ago

0.72.0

3 months ago

0.71.1

4 months ago

0.70.1

4 months ago

0.71.0

4 months ago

0.69.1

5 months ago

0.68.0

5 months ago

0.69.0

5 months ago

0.67.0

6 months ago

0.66.1

6 months ago

0.66.0

6 months ago

0.65.0

7 months ago

0.64.1

7 months ago

0.64.0

7 months ago

0.63.0

7 months ago

0.62.0

7 months ago

0.61.0

7 months ago

0.60.0

8 months ago

0.59.0

8 months ago

0.58.0

8 months ago

0.57.0

8 months ago

0.56.1

8 months ago

0.56.0

8 months ago

0.55.0

8 months ago

0.54.1

8 months ago

0.54.0

8 months ago

0.53.0

9 months ago