diff --git a/lib/connectToDevice.js b/lib/connectToDevice.js index dbe79ff..43b179c 100644 --- a/lib/connectToDevice.js +++ b/lib/connectToDevice.js @@ -38,6 +38,7 @@ module.exports = function(options) { // Error handling - make sure to always release the handle handle.release(); + e.device = null; throw e; }) .then(device => { diff --git a/lib/network.js b/lib/network.js index 941bab1..d3a27c8 100644 --- a/lib/network.js +++ b/lib/network.js @@ -323,10 +323,12 @@ class DeviceInfo { // Could not call the info method, this might be either a timeout or a token problem const e = new Error('Could not connect to device, token might be wrong'); e.code = 'connection-failure'; + e.device = this; throw e; } else { const e = new Error('Could not connect to device, token needs to be specified'); e.code = 'missing-token'; + e.device = this; throw e; } });