Skip to content

Commit

Permalink
Change throw error to reject error
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb committed Jun 27, 2018
1 parent f07a2a5 commit af18dbe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ See the [docs](https://codetheweb.github.io/tuyapi/index.html).
1. Document details of protocol
2. Retry when ECONNRESET is thrown
3. Figure out correct CRC algorithm
4. Keep connection open between requests

## Contributors

Expand Down
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ TuyaDevice.prototype.resolveId = function (options) {
};

/**
* @deprecated since v3.0.0. Will be deleted in v4.0.0. Use resolveId() instead.
* @deprecated since v3.0.0. Will be removed in v4.0.0. Use resolveId() instead.
*/
TuyaDevice.prototype.resolveIds = function (options) {
// eslint-disable-next-line max-len
console.warn('resolveIds() is deprecated since v3.0.0. Will be deleted in v4.0.0. Use resolveId() instead.');
console.warn('resolveIds() is deprecated since v3.0.0. Will be removed in v4.0.0. Use resolveId() instead.');
return this.resolveId(options);
};

Expand Down Expand Up @@ -252,7 +252,8 @@ TuyaDevice.prototype._send = function (ip, buffer) {
client.write(buffer);

const timeout = setTimeout(() => {
throw new Error('Timeout waiting for response');
client.destroy();
reject(new Error('Timeout waiting for response'));
}, this._responseTimeout * 1000);

function done() {
Expand Down

0 comments on commit af18dbe

Please sign in to comment.