From 62723d85f0e775df681983c6eb1ebdae591daa70 Mon Sep 17 00:00:00 2001 From: mmorrison Date: Tue, 15 Oct 2019 14:47:22 -0500 Subject: [PATCH] Cherry-picked: Reject only with Error instead of Object or String Fixes #132 --- protocols/core.js | 2 +- protocols/nadeo.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/core.js b/protocols/core.js index a21a331..9791970 100644 --- a/protocols/core.js +++ b/protocols/core.js @@ -39,7 +39,7 @@ class Core extends EventEmitter { let abortCall = null; this.abortedPromise = new Promise((resolve,reject) => { - abortCall = () => reject("Query is finished -- cancelling outstanding promises"); + abortCall = () => reject(new Error("Query is finished -- cancelling outstanding promises")); }); // Make sure that if this promise isn't attached to, it doesn't throw a unhandled promise rejection diff --git a/protocols/nadeo.js b/protocols/nadeo.js index 7b46788..55041b2 100644 --- a/protocols/nadeo.js +++ b/protocols/nadeo.js @@ -80,7 +80,7 @@ class Nadeo extends Core { const sentPromise = new Promise(async (resolve,reject) => { client.methodCall(cmd, params, (err, value) => { - if (err) reject('XMLRPC error ' + JSON.stringify(err)); + if (err) reject(new Error('XMLRPC error ' + JSON.stringify(err))); resolve(value); }); });