Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
@fuel-ts/errors
Advanced tools
Error class and error codes that the fuels-ts library throws
@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.
pnpm add @fuel-ts/errors
# or
npm add @fuel-ts/errors
import { FuelError, ErrorCodes } from "@fuel-ts/error";
export function singleImport() {
throw new FuelError(FuelError.CODES.INVALID_DATA, "Invalid data");
}
export function multipleImports() {
throw new FuelError(ErrorCodes.INVALID_DATA, "Invalid data");
}
You can use the expectToThrowFuelError
test utility when asserting errors.
// can also be imported from `fuels` when using the umbrella package
import { expectToThrowFuelError } from "@fuel-ts/errors";
import { myFn } from "...";
describe('this and that' () => {
const code = FuelError.CODES.INVALID_DATA;
it("should throw FuelError", async () => {
const expected = new FuelError(code);
await expectToThrowFuelError(() => myFn(), expected);
});
it("should throw something else", async () => {
const expected = new FuelError(code);
const fn = () => expectToThrowFuelError(() => myFn(), expected)
await expect(fn).rejects.toThrow('Something else');
});
})
import { FuelError, Provider } from "fuels";
type Locale = "pt-BR" | "bs-BA" | "en-GB";
const currentLocale: Locale = "pt-BR";
const i18nDict = {
pt-BR: {
[FuelError.CODES.INVALID_DATA]: "Dados inválidos",
},
bs-BA: {
[FuelError.CODES.INVALID_DATA]: "Nevažeći podaci",
},
en-GB: {
[FuelError.CODES.INVALID_DATA]: "Invalid data",
},
};
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 });
}
};
In order to contribute to @fuel-ts/errors
, please see the main fuels-ts monorepo.
The @fuel-ts/errors
changelog can be found at CHANGELOG.
The primary license for @fuel-ts/errors
is Apache 2.0
, see LICENSE.
FAQs
Error class and error codes that the fuels-ts library throws
The npm package @fuel-ts/errors receives a total of 15,915 weekly downloads. As such, @fuel-ts/errors popularity was classified as popular.
We found that @fuel-ts/errors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.