joyent/node — pull request #6352 by rvagg (2013-10-15 08:08:24+00:00)
Title: util: format as Error if instanceof Error

Duplicate of #6350 but against master as per [comment](https://github.com/joyent/node/pull/6350#issuecomment-26314644)

> Custom errors, subclasses of `Error` at least, should show up as errors and not empty objects with `util.format()` / `console.log()`. The `objectToString()` / `Object.prototype.toString()` call reaches in to the `instance_class_name` which I'm pretty sure we can't set in JS-land to make it return `[object Error]` hence the switch to `instanceof`.

> Background: errors produced by [errno's custom error utility](https://github.com/rvagg/node-errno/blob/master/custom.js) produce `'{}'` with `console.log()`.