package
Make your own nested error types!
npm install make-error-causeGitHub-flavored package documentation.
Across all versions, last 30 days.
3,390,390 in 30 days
Runtime metadata.
Tagged topics.
Make your own nested errors.
instanceofinspect())fullStack(err)make-errornpm install make-error-cause --saveimport { BaseError, fullStack } from "make-error-cause";
class CustomError extends BaseError {
constructor(message, cause) {
super(message, cause);
}
}
const error = new Error("Boom!");
const customError = new CustomError("Another boom!", error);
console.log(customError); // Automatically prints full stack trace using `fullStack(this)`.
console.log(customError.cause); // Check causes via the `.cause` property.
console.log(customError instanceof Error); //=> trueInspired by verror, and others, but created lighter and without core dependencies for browser usage.
Other references:
Apache 2.0
Estimated unpacked size across 2 packages.
20.2 kB
Includes dependencies.