function extendToJSON (error) {
error.toJSON = errorToJSON;

// Also add an inspect() method, for compatibility with Node.js' `util.inspect()` method
error.inspect = errorToString;
}
JavaScript engines differ in how errors are serialized to JSON - especially when it comes
to custom error properties and stack traces.  So we add our own toJSON method that ALWAYS
outputs every property of the error.