joyent/node — pull request #6350 by rvagg (2013-10-15 01:33:52+00:00)
Title: util: format as Error if instanceof Error

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()`.