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

Catch out all Promises #402

Open
Tomato6966 opened this issue Dec 6, 2021 · 8 comments
Open

Catch out all Promises #402

Tomato6966 opened this issue Dec 6, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@Tomato6966
Copy link

Just catch out all promises in the next version please!

channel.send().catch(() => {})

members.fetch().catch(() => {});

Etc.

@Tomato6966 Tomato6966 added the enhancement New feature or request label Dec 6, 2021
@Dragonizedpizza
Copy link
Contributor

isn't that bad

@Tomato6966
Copy link
Author

U can add a debug option to allow users to enable or disable log information(s)

@Compositr
Copy link

I suggest that instead of just

<Promise>.catch(()=>{})

There should be a logger function or some sort of error handling that would handle Promise rejections gracefully and log it out to the console, with options to enable verbose messages

Something like this perhaps (just example, to get an idea about what I'm suggesting)

function logger(err) {
  // Do something to make error pretty for console.log
  console.log(err)
}

// So when catching a Promise

<Promise>.catch(logger)

@imranbarbhuiya
Copy link
Contributor

I suggest catching all promises as u said and instead of using a logger. Just emit a error event in gwsManager with the error and the gw so there is no need to enable/disable debug option. U can just listen to that event if u want.

@Dragonizedpizza
Copy link
Contributor

Dragonizedpizza commented Jan 3, 2022

I'd suggest doing either:

Manager.start(...).catch(() => {});

in your code, or add a debug option to the module like tomato said,

Manager.start({ ..., debug: false /* true by default */ });

which does catch the promises.

@Nico105
Copy link
Collaborator

Nico105 commented Jan 3, 2022

I suggest catching all promises as u said and instead of using a logger. Just emit a error event in gwsManager with the error and the gw so there is no need to enable/disable debug option. U can just listen to that event if u want.

I would favor a event one too. I mean mongoose and I think other modules do it with a event too right?

@Nico105
Copy link
Collaborator

Nico105 commented Jan 3, 2022

I'd suggest doing either:

Manager.start(...).catch(() => {});

in your code, or add a debug option to the module like tomato said,

Manager.start({ ..., debug: false /* true by default */ });

which does catch the promises.

the first one would just catch the error of the start function no? Not the ones during runtime.

@Dragonizedpizza
Copy link
Contributor

ah yeah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants