propagate errors in ClientManager.destroy (#844)

If the promise returned by logout() rejects, previously
it would be completely uncaught, and just return an
eternally pending promise that never resolved.

Related to pull requests #828 and #839.
This commit is contained in:
isonmad
2016-10-27 06:33:51 -04:00
committed by Amish Shah
parent b8c11f0bed
commit dd31ee0c5f

View File

@@ -58,10 +58,10 @@ class ClientManager {
} }
destroy() { destroy() {
return new Promise((resolve) => { return new Promise((resolve, reject) => {
this.client.ws.destroy(); this.client.ws.destroy();
if (!this.client.user.bot) { if (!this.client.user.bot) {
this.client.rest.methods.logout().then(resolve); this.client.rest.methods.logout().then(resolve, reject);
} else { } else {
resolve(); resolve();
} }