Code Monkey home page Code Monkey logo

Comments (7)

micalevisk avatar micalevisk commented on May 8, 2024 1

So you're basically proposing a no-op on errors for event handlers.

What about adding a new option to the OnEvent instead. Both aren't that flexible tho...

from event-emitter.

micalevisk avatar micalevisk commented on May 8, 2024 1

yes. I didn't know about that flag

it('should be able to gracefully recover when an unexpected error occurs from provider and suppressErrors is true', async () => {
const eventsConsumerRef = app.get(EventsProviderConsumer);
await app.init();
const emitter = app.get(EventEmitter2);
const result = emitter.emit('error-handling-suppressed.provider');
expect(eventsConsumerRef.errorHandlingCalls).toEqual(1);
expect(result).toBeTruthy();
});

@OnEvent('error-handling-suppressed.provider', { suppressErrors: true })
onErrorHandlingSuppressedEvent() {
this.errorHandlingCalls++;
throw new Error('This is a test error');
}

from event-emitter.

koreanddinghwan avatar koreanddinghwan commented on May 8, 2024 1

@koreanddinghwan the docs is missing that feature as well

feel free to open a PR to update it https://docs.nestjs.com/techniques/events

got it, i'm not good at open-source contribute, and it will be the first time, but i'll gonna try it, thank you for your help!

from event-emitter.

koreanddinghwan avatar koreanddinghwan commented on May 8, 2024

So you're basically proposing a no-op on errors for event handlers.

What about adding a new option to the OnEvent instead. Both aren't that flexible tho...

import { OnOptions } from 'eventemitter2';
export declare type OnEventOptions = OnOptions & {
    prependListener?: boolean;
    suppressErrors?: boolean;
};

is suppressErrors do the samething as i suggested?

from event-emitter.

koreanddinghwan avatar koreanddinghwan commented on May 8, 2024

thank you,
in korea, i saw a blog about 'when event handler do not catch exception, server stops with runtime error'

blogs

but, i cannot reproduce that behavior.

or, somewhere in

i've already make 'onSafeEvent' decorator in my project, but... should it needed?

i think that if we wanna log eventHandler's exception , then use the custom decorator is fine.

oh, i found PR #936 , the blogs is too old, thank you!

from event-emitter.

micalevisk avatar micalevisk commented on May 8, 2024

@koreanddinghwan the docs is missing that feature as well

feel free to open a PR to update it https://docs.nestjs.com/techniques/events

from event-emitter.

koreanddinghwan avatar koreanddinghwan commented on May 8, 2024

nestjs/docs.nestjs.com#2888

from event-emitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.