Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including error-format with all npm packages installed. Try it out:

var errorFormat = require("error-format")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

error-format v1.0.1

Allows you to customize the toString method of passed `err`. Also adds useful properties like `line`, `filename` and `column` to the `err` object.

error-format The MIT License

Allows you to customize the toString method of passed err. Also adds useful properties like line, filename and column to the err object.

code climate standard code style travis build status coverage status dependency status


npm i error-format --save


For more use-cases see the tests

const errorFormat = require('error-format')


Adds bypassed .toString which you can customize through the fmt function.


  • <err> {Error}: error object/instance
  • [fmt] {Function}: custom format function
  • returns {Error}: what comes from input (instance of error)


var errorFormat = require('error-format')
var err = new TypeError('baz qux')

// => 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

// => TypeError: baz qux --- Line: 4 --- Column: 11



Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the guidelines.

Charlike Make Reagent new message to charlike freenode #charlike keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free