errlop

  • Version 4.5.0
  • Published
  • 52.3 kB
  • No dependencies
  • MIT license

Install

npm i errlop
yarn add errlop
pnpm add errlop

Overview

An extended Error class that envelops a parent error, such that the stack trace contains the causation

Index

Classes

class Errlop

class Errlop extends Error {}

    constructor

    constructor(input: PotentialError, parent?: Errlop | Error);
    • Create an instance of an error, using a message, as well as an optional parent. If the parent is provided, then the fullStack property will include its stack too

    property ancestors

    ancestors: (Errlop | Error)[];
    • An array of all the ancestors. From parent, to grand parent, and so on.

    property exitCode

    exitCode?: string | number;
    • A numeric code to use for the exit status if desired by the consumer. It cycles through [input, this, ...ancestors] until it finds the first [exitCode, errno, code] that is valid.

    property klass

    klass: typeof Errlop;
    • Duck typing as node 4 and intanceof does not work for error extensions

    property orphanStack

    orphanStack: string;
    • The stack for our instance alone, without any parents. If the input contained a stack, then use that.

    property parent

    parent?: Errlop | Error;
    • The parent error if it was provided. If a parent was provided, then use that, otherwise use the input's parent, if it exists.

    property stack

    stack: string;
    • The stack which now contains the accumalated stacks of its ancestors. This is used instead of an alias like fullStack or the like, to ensure existing code that uses err.stack doesn't need to be changed to remain functional.

    method create

    static create: (input: PotentialError, parent?: Errlop | Error | null) => Errlop;
    • Syntatic sugar for Errlop class creation. Enables Errlop.create(...args) to achieve new Errlop(...args)

    method ensure

    static ensure: (value: any) => Errlop;
    • Ensure that the value is an Errlop instance

    method isErrlop

    static isErrlop: (value: any) => boolean;
    • Check whether or not the value is an Errlop instance

    Package Files (1)

    Dependencies (0)

    No dependencies.

    Dev Dependencies (17)

    Peer Dependencies (0)

    No peer dependencies.

    Badge

    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/errlop.

    • Markdown
      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/errlop)
    • HTML
      <a href="https://www.jsdocs.io/package/errlop"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>