Package Exports
- error-format
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 (error-format) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
error-format

Allows you to customize the toString method of passed
err. Also adds useful properties likeline,filenameandcolumnto theerrobject.
Install
npm i error-format --saveUsage
For more use-cases see the tests
const errorFormat = require('error-format')errorFormat
Adds bypassed
.toStringwhich you can customize through thefmtfunction.
Params
<err>{Error}: error object/instance[fmt]{Function}: custom format functionreturns{Error}: what comes from input (instance of error)
Example
var errorFormat = require('error-format')
var err = new TypeError('baz qux')
console.log(err.toString())
// => TypeError: baz qux
err = errorFormat(err, function fmt (headline) {
if (this.message.indexOf('baz') !== -1) {
headline += ' --- Line: ' + this.line
}
if (this.message.indexOf('qux') !== -1) {
headline += ' --- Column: ' + this.column
}
return headline
})
console.log(err.toString())
// => TypeError: baz qux --- Line: 4 --- Column: 11Related
- error-base: Create custom Error classes. | homepage
- is-typeof-error: Check that given value is any type of error and instanceof Error. | homepage
- is-kindof: Check type of given javascript value. Support promises, generators, streams, and native types… more | homepage
- kind-error: Base class for easily creating meaningful and quiet by default Error classes with sane… more | homepage
- kind-of: Get the native type of a value. | homepage
- kind-of-extra: Additional functionality to
kind-oftype check utility, support promises, generators… more | homepage - kind-of-types: List of all javascript types. Used and useful for checking, validation, sanitizing and… 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.