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

Globally intercept methods decorated with @OnEvent #655

Open
bmassemin opened this issue Jan 29, 2024 · 1 comment
Open

Globally intercept methods decorated with @OnEvent #655

bmassemin opened this issue Jan 29, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@bmassemin
Copy link

Hi and thank you for your library.

I'm not an expert with NestJS, so I'm not sure how to resolve this issue:
I would like to intercept the exceptions thrown by method decorated by @OnEvent.
Every exception thrown by the the http controller are well captured by your lib, but not the @OnEvent methods.
Thanks 🙏

@mentos1386 mentos1386 added the enhancement New feature or request label Feb 23, 2024
@mentos1386
Copy link
Owner

Looking at @nestjs/event-emitter code/docs I'm not sure if this is possible ti implement with "interceptors" as we do now. I can't find any reference that Interceptors (or enhancers in general) can be applied to the @OnEvent.

But, we could still support this use case. But we would have to introduce something like @Raven(options) (or some other name) decorator which would have to be applied to every @OnEvent method.

Example:

@Raven()
@OnEvent('order.created')
handleOrderCreatedEvent(payload: OrderCreatedEvent) {
  // handle and process "OrderCreatedEvent" event
}

I'm willing to support anyone wanting to start working on this feature. This would be an implementation of ordinary typescript decorator that would wrap the method and call captureException method if error happened. The captureException method might have to be moved outside of class to be able to call it.

@mentos1386 mentos1386 added the good first issue Good for newcomers label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants