codetheweb / tuyapi

🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.
MIT License
2.08k stars 342 forks source link

Change to throw on index.js line 281 #43

Closed tomporter518 closed 6 years ago

tomporter518 commented 6 years ago

I'm having issues since the change to throw on index.js line 281. It seems execution completely halts and does not get caught when _send is being executed, if there is an error. I get:

Scripts/node_modules/tuyapi/index.js:281
          throw err;
          ^

Error: Error communicating with device. Make sure nothing else is trying to control it or connected to it.
    at _errnoException (util.js:992:11)
    at TCP.onread (net.js:618:25)

,though the former error(err) line seemed to be functional. I'm not a Node expert but it seems now I can't rely on the reject Promise from the set method such that I can perform retries because I don't actually get it. Any thoughts?

codetheweb commented 6 years ago

You're right, thanks for catching that. Pull from master and try again, it should be fixed now.