error-format

Allows you to customize the toString method of passed
err
. Also adds useful properties likeline
,filename
andcolumn
to theerr
object.
Install
npm i error-format --save
Usage
For more use-cases see the tests
const errorFormat =
errorFormat
Adds bypassed
.toString
which you can customize through thefmt
function.
Params
<err>
{Error}: error object/instance[fmt]
{Function}: custom format functionreturns
{Error}: what comes from input (instance of error)
Example
var errorFormat = var err = 'baz qux' console// => TypeError: baz qux err = console// => TypeError: baz qux --- Line: 4 --- Column: 11
Related
- error-base: Create custom Error classes. | homepage
- is-typeof-error: Check that given value is any type of error and… more | homepage
- kind-error: Base class for easily creating meaningful and quiet by default… more | homepage
- kind-of: Get the native type of a value. | homepage
- kind-of-extra: Additional functionality to
kind-of
type check utility, support promises, generators,… more | homepage - kind-of-types: List of all javascript types. Used and useful for checking,… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.