Relative Content

Tag Archive for node.jserror-handlingmiddleware

Node js getting error message from a model to the errorhandler middleware

So the idea is that I have a controller that asks an object in a model to make a document in the database. I have a middleware that triggers after an error is thrown in the controller. But if an error is thrown in the model then it is not caught by the errorHandeler. Now my question is if that is posible to do. I can catch the error in the model and then the server doesn’t crash, however I don’t know how to give the info about that to the frontend.