Package Exports
- @arrows/error
- @arrows/error/createErrorClass
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@arrows/error) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@arrows/error
Table of contents
Introduction
The library contains a set of helper functions for error handling.
The library has built-in type definitions, which provide an excellent IDE support.
Installation
Via NPM:
npm i @arrows/errorVia Yarn:
yarn add @arrows/errorAPI reference
createErrorClass
Creates custom error class that returns extended error object that can be serialized to JSON.
Parameters
name- The error name (should be the same as the name of the variable to which the class is assigned)message- Error messageserializeStacktraceAn optional boolean flag, to indicate weather a stacktrace should be serialized (default: false)
Returns
- Returns custom error class that takes one optional argument - error details
Interface
(name , message, serializeStacktrace?) => custom_error_classExamples
Create a custom error class:
const MyError = createErrorClass('MyError', 'some message')Create a custom error class with serializable stacktrace:
const MyError = createErrorClass('MyError', 'some message', true)License
Project is under open, non-restrictive ISC license.