Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation on customization of error resopnse incorrect #1438

Closed
3 tasks done
DonutEspresso opened this issue Aug 6, 2017 · 0 comments
Closed
3 tasks done

Documentation on customization of error resopnse incorrect #1438

DonutEspresso opened this issue Aug 6, 2017 · 0 comments
Labels

Comments

@DonutEspresso
Copy link
Member

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants