Open
Description
Prerequisites
- I have written a descriptive issue title
- 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
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:
{
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