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

Mongoose global error event #7125

Closed
NishantDesai1306 opened this issue Oct 11, 2018 · 4 comments
Closed

Mongoose global error event #7125

NishantDesai1306 opened this issue Oct 11, 2018 · 4 comments
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone

Comments

@NishantDesai1306
Copy link

Feature query

I was wondering is there's some way to get all errors in mongoose like some sort of global error event on mongoose or even at a collection level ?

node version: 8.11.3
mongoose version: 4.13.6

@vkarpov15 vkarpov15 added this to the 5.4 milestone Oct 15, 2018
@vkarpov15
Copy link
Collaborator

This is a great idea. We should add the ability to handle errors at the model level and the connection level. Right now the closest thing we have is a Model.on('error') event, but that only catches errors from index builds and uncaught errors in callbacks.

@vkarpov15 vkarpov15 added the enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature label Oct 15, 2018
vkarpov15 added a commit that referenced this issue Dec 13, 2018
@sibelius
Copy link
Contributor

sibelius commented Mar 8, 2022

do we have a global way of getting all errors?

mongoose.on('') ?

@Loveyless
Copy link

+1

@vkarpov15
Copy link
Collaborator

@sibelius not for all errors. You'd need to register an error handler on every model, for (const model of Object.values(mongoose.models)) { model.on('error', ...) }

@Automattic Automattic deleted a comment from trsh Aug 3, 2022
@Automattic Automattic locked and limited conversation to collaborators Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Projects
None yet
Development

No branches or pull requests

5 participants