discord-giveaways
discord-giveaways copied to clipboard
Catch out all Promises
Just catch out all promises in the next version please!
channel.send().catch(() => {})
members.fetch().catch(() => {});
Etc.
isn't that bad
U can add a debug option to allow users to enable or disable log information(s)
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)
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'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.
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?
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.
ah yeah