homey-api 1.5.11 → 1.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/APIErrorTimeout.js +21 -0
- package/lib/Util.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const APIError = require('./APIError');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @class
|
|
9
|
+
* @hideconstructor
|
|
10
|
+
* @extends APIError
|
|
11
|
+
* @memberof HomeyAPI
|
|
12
|
+
*/
|
|
13
|
+
class APIErrorTimeout extends APIError {
|
|
14
|
+
|
|
15
|
+
constructor(message, statusCode = 408) {
|
|
16
|
+
super(message, statusCode);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = APIErrorTimeout;
|
package/lib/Util.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
+
const APIErrorTimeout = require('./APIErrorTimeout');
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Helper Utility Class
|
|
7
9
|
* @class
|
|
@@ -43,7 +45,7 @@ class Util {
|
|
|
43
45
|
* @returns {Promise}
|
|
44
46
|
*/
|
|
45
47
|
static async timeout(promise, timeoutMillis = 5000, message = `Timeout after ${timeoutMillis}ms`) {
|
|
46
|
-
const timeoutError = new
|
|
48
|
+
const timeoutError = new APIErrorTimeout(message);
|
|
47
49
|
let timeoutRef;
|
|
48
50
|
return Promise.race([
|
|
49
51
|
promise,
|