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

Add information to docs on how to add additional fields in error #8

Closed
vladshcherbin opened this issue Apr 18, 2020 · 2 comments
Closed

Comments

@vladshcherbin
Copy link

Jesus, I've spent so much time to find how to do it.

http-errors has possibility to add additional fields to error like this:

createError(503, 'No work on the sabbath.', { type: 'DayError' , expose: true })

However, formatError function cuts all additional properties and produces only message field. To add this additional error fields you have to use extensions property like this:

createError(503, 'No work on the sabbath.', { extensions: { type: 'DayError' }, expose: true })

This will correctly show additional error information to user:

image

Please, add this to docs somewhere. I really hope it will help and save time for someone else.

❤️

@jaydenseric
Copy link
Owner

Just published graphql-api-koa@4.1.2, this stuff should be easier now 🙏

@vladshcherbin
Copy link
Author

@jaydenseric thank you a lot, using it in my current project ❤️

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

No branches or pull requests

2 participants