ITADN

Implement RFC7807

#64OpenUzlopak 创建于 2022-02-21
enhancementgood first issue
U
Uzlopakcommented
### Prerequisites - [X] I have written a descriptive issue title - [X] I have searched existing issues to ensure the feature has not already been requested ### 🚀 Feature Proposal We could implement a toRFC7807-method, which creates RFC7807-compatible JSON Response to FastifyError and use it in fastify 4 by default. So we could create a new Error like this ```javascript const NewError = createError('CODE', 'hey %s, I like your %s %s') const err = new NewError('alice', 'attitude', 'see you') ``` and then the resulting JSON would be: ```javascript { type: "FastifyError", title: "FastifyError", status: 500, // <-- statusCode detail: 'hey alice, I like your attitude', // <-- message instance: '', // <-- here could be the route code: 'CODE', details: { }, // here could be the ajv error codes. } ``` ### Motivation _No response_ ### Example _No response_
9 条评论