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

fix: Catching in controllers does not have any effect when an error are thrown in another services #1376

Open
joseaburt opened this issue Aug 12, 2024 · 1 comment
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.

Comments

@joseaburt
Copy link

Description

image

As the image shows the client is getting the exact domain service error and the controller normal try/catch does not have any effect. Something like Reflection stuff behind can be causing this.

@joseaburt joseaburt added status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature. labels Aug 12, 2024
@lukaszzdanikowski
Copy link

@joseaburt looking at the example it is an async/await issue - findOne is async so you should use await in line 19 of your controller - this will allow you to catch an error thrown from the service. Current code just returns rejected promise which is resolved by express, after returning from controller so outside of try block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.
Development

No branches or pull requests

2 participants