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

How to catch @nest/config (Joi) exceptions? #97

Closed
Baterka opened this issue Feb 25, 2020 · 3 comments
Closed

How to catch @nest/config (Joi) exceptions? #97

Baterka opened this issue Feb 25, 2020 · 3 comments
Labels
question Further information is requested

Comments

@Baterka
Copy link

Baterka commented Feb 25, 2020

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[X] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I setuped configuration validation as described in documentation of NestJS: https://docs.nestjs.com/techniques/configuration#schema-validation

Validation works as expected, but when my .env file is not valid, I am getting plain error, for example:

Error: Config validation error: "FOO_BAR" is required at Function.forRoot (@nestjs\config\dist\config.module.js:44:27)

This error is not thrown by Nest so approach with globalFilter what can catch every Nest error not work: https://docs.nestjs.com/websockets/exception-filters#exception-filters

Can this be described in documentation?

@kamilmysliwiec kamilmysliwiec added the question Further information is requested label Feb 28, 2020
@kamilmysliwiec
Copy link
Member

What's the use-case here?

@Baterka
Copy link
Author

Baterka commented Feb 29, 2020

Having errors catchable to be able to reformat them, or at least having them in NestJS exception format (for example like @nestjs/typeorm errors).
Or maybe just use Nest's logger to throw errors? I am working on it in fork :)

@kamilmysliwiec
Copy link
Member

PRs are more than welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants