Fejl is a JavaScript and TypeScript utility library designed to streamline the creation and management of custom error classes in Node.js applications. Currently in its stable v4.0.1 release, Fejl offers a predictable release cadence with major versions typically introducing significant changes like ESM support or Node.js version bumps. Its core functionality revolves around `MakeErrorClass`, which allows developers to define custom error types with default messages and properties, drastically reducing boilerplate compared to native `Error` extension. Key differentiators include static `assert` and `makeAssert` methods for concise conditional error throwing, and a collection of pre-defined HTTP error classes. Fejl aims to improve code readability and maintainability by centralizing error definitions and providing convenient assertion patterns.
npm install fejlVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating a custom error class with default properties, handling it, and using static assertion methods with built-in HTTP errors.
Migrate your codebase to use ES module `import` statements. If you were directly leveraging `make-error` internals, you may need to refactor your custom error definitions.
Upgrade your Node.js runtime environment to version 18 or newer.
If you need a dynamic message, either define the error class without a default message, or store the dynamic message in a custom property on the error instance, rather than relying on it to override the default `message`.
Upgrade Node.js to version 14 or higher (or 18+ if using Fejl v4).
Change your import statements from `const { Symbol } = require('fejl');` to `import { Symbol } from 'fejl';` and ensure your project is configured for ES Modules (e.g., `"type": "module"` in `package.json`).Ensure `MakeErrorClass` is imported correctly using `import { MakeErrorClass } from 'fejl'` for ESM projects. The function itself returns a class constructor, so you would extend it, not instantiate it directly: `class MyError extends MakeErrorClass(...) {}`.This is the intended behavior of `fejl`. If you need a dynamic error message, either create the class without a default message: `class MyError extends MakeErrorClass() {}`, or pass your dynamic message as a custom property: `new MyError(null, { myDynamicMessage: '...' })`.No dependency data recorded yet.