Options
All
  • Public
  • Public/Protected
  • All
Menu

errorish 1.0.0

Index

Classes

Interfaces

Type aliases

Functions

Type aliases

NormalError

NormalError<T>: T & Record<"stack", string>

A normalized Error. See normalize.

Type parameters

  • T: Error

Functions

capture

  • capture<T>(error: T): T
  • Runs Error.captureStackTrace if running V8 to clean up the error stack trace.

    Type parameters

    • T: Error

    Parameters

    • error: T

    Returns T

ensure

  • ensure<T, U, E>(error: T, create?: UnaryFn<T, U> | Empty, options?: EnsureOptions<E> | Empty): T extends E ? T : U
  • Will return error if an instance of Error is passed; otherwise, when lacking a create function, it will instantiate an Exception and return it. When a new Exception is created, Exception.data will be populated with error.

    Type parameters

    • T

    • U: Error

    • E: Error

    Parameters

    • error: T

      a target object

    • Optional create: UnaryFn<T, U> | Empty

      an optional error returning function to run when error is not an instance of Error

    • Optional options: EnsureOptions<E> | Empty

    Returns T extends E ? T : U

normalize

  • Normalizes an error -it assumes an instance of Error is passed. Guarantees the error will have a name, message, and stack properties.

    Type parameters

    • T: Error

    Parameters

    Returns NormalError<T>

Generated using TypeDoc