Closed
Description
- Used appropriate template for the issue type
- Searched both open and closed issues for duplicates of this issue
- Title adequately and concisely reflects the feature or the bug
Bug Report
Example of how to customize errors in restify 5.x docs is incorrect.
Restify Version
Docs site for 5.x.
Node.js Version
All
Expected behaviour
On the server API page (http://restify.com/docs/server-api/), example shows
server.on('InternalServer', function(req, res, err, callback) {
err.body = 'Sorry, an error occurred!';
return callback();
});
But the returned value to client is still {}
.
Actual behaviour
We should be asking folks to implement a custom toJSON in their error listeners instead:
server.on('restifyError', function(req, res, err, callback) {
err.toJSON = function customToJSON() {
return 'i just want a string';
};
return callback();
});
Cause
More details on restify/errors#72.
Are you willing and able to fix this?
Yes