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
How to import fastify error codes? #4250
Comments
Also dont forget that fastify plugins have their own errors. Maybe we should register those errors also? |
I'd like to do this. Assign it to me please, if @teemupiiroinenwirepas don't mind. |
This integration would be nice, but it should be transparent for the |
Let's not include plugins. |
I can't understand how this frameworkErrors example is supposed to work while we can't import |
Should we export only error codes (string names) or the errors produced by Error codes: const fastify = require('fastify')
exampleErrorHandler((err) => {
if (err.code === fastify.errorCodes.FST_ERR_NOT_FOUND) {
//
}
}) Errors: const fastify = require('fastify')
exampleErrorHandler((err) => {
if (err instanceof fastify.errorCodes.FST_ERR_NOT_FOUND) {
//
}
}) As I guess we shouldn't export the |
The latter 👍🏽
Yes, there is not value for the user getting it |
Discussed in #3842
Originally posted by teemupiiroinenwirepas April 20, 2022
We would like to map fastify error codes from https://github.com/fastify/fastify/blob/main/lib/errors.js to our own error codes, but we cannot find a way how to import the codes. How the importing should be done, or how the error code mapping should be done to the application specific error codes?
Br,
Teemu
We should:
The text was updated successfully, but these errors were encountered: