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

Strict amount of parameters, change input to array or object #117

Open
2 tasks done
Tracked by #119
Uzlopak opened this issue Sep 28, 2023 · 2 comments
Open
2 tasks done
Tracked by #119

Strict amount of parameters, change input to array or object #117

Uzlopak opened this issue Sep 28, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Uzlopak
Copy link
Contributor

Uzlopak commented Sep 28, 2023

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Maybe it makes sense to have a strict amount of parameters. So when the format string is '"%s is not a valid %s", then we need to provide exact two parameters. If you provide zero, one or more than two parameters, we have an issue. Like nodejs errors are done. This would result in the ability to say, that the last parameter is e.g. used for "cause" or other options.

Now the implementation of #116 is kind of messy. But not because of the contributor but because our code is not good enough.

This would be a semver-major.

Also we could then use #103 and avoid the use of util format, making it platform independent. Maybe also usable in browser.

@Uzlopak Uzlopak added the enhancement New feature or request label Sep 28, 2023
@mcollina
Copy link
Member

I'm +1 for the change.

@jsumners
Copy link
Member

If a major is required, I still suggest going one further:

const createError = fastifyError({
	code: 'ERROR_CODE',
	message: '%s did bad stuff, because %s'
})

const instance = createError({
	messageParams: ['Foo', 'bad syntax'],
	cause: Error('boom')
})

@Uzlopak Uzlopak mentioned this issue Oct 14, 2023
2 tasks
@Uzlopak Uzlopak changed the title Strict amount of parrameters Strict amount of parameters, change input to array or object Oct 14, 2023
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