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

Implement RFC7807 #64

Open
2 tasks done
Tracked by #119
Uzlopak opened this issue Feb 21, 2022 · 6 comments
Open
2 tasks done
Tracked by #119

Implement RFC7807 #64

Uzlopak opened this issue Feb 21, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@Uzlopak
Copy link
Contributor

Uzlopak commented Feb 21, 2022

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

@mcollina
Copy link
Member

This would be interesting. It might be too late for Fastify v4 but would you like to assemble a PR anyway?

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Feb 22, 2022

Is fastify-error the right place? Or should it be done in a different place?

@mcollina
Copy link
Member

It should be done both here and in Fastify

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Oct 14, 2023

Reopening for #119

@Uzlopak Uzlopak reopened this Oct 14, 2023
@Uzlopak Uzlopak mentioned this issue Oct 14, 2023
2 tasks
@Uzlopak Uzlopak added the enhancement New feature or request label Oct 14, 2023
@mcollina
Copy link
Member

How about we ads a new factory for RFC7807 errors?

@jsumners
Copy link
Member

How about we ads a new factory for RFC7807 errors?

Seems like a good solution.

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

No branches or pull requests

3 participants