homey-api 3.4.18 → 3.4.19
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/APIError.js +1 -1
- package/lib/HomeyAPI/HomeyAPIV3/Manager.js +19 -21
- package/lib/HomeyAPI/HomeyAPIV3.js +31 -9
- package/package.json +1 -1
package/lib/APIError.js
CHANGED
|
@@ -287,27 +287,25 @@ class Manager extends EventEmitter {
|
|
|
287
287
|
uri: this.uri,
|
|
288
288
|
},
|
|
289
289
|
(err, result) => {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
err.statusCode || err.code || 500
|
|
310
|
-
);
|
|
290
|
+
if (err != null) {
|
|
291
|
+
if (typeof err === 'object') {
|
|
292
|
+
err = new HomeyAPIError(
|
|
293
|
+
{
|
|
294
|
+
stack: err.stack,
|
|
295
|
+
error: err.error,
|
|
296
|
+
error_description: err.error_description,
|
|
297
|
+
},
|
|
298
|
+
err.statusCode || err.code || 500
|
|
299
|
+
);
|
|
300
|
+
} else if (typeof err === 'string') {
|
|
301
|
+
err = new HomeyAPIError(
|
|
302
|
+
{
|
|
303
|
+
error: err,
|
|
304
|
+
},
|
|
305
|
+
500
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
311
309
|
return reject(err);
|
|
312
310
|
}
|
|
313
311
|
|
|
@@ -843,7 +843,20 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
843
843
|
|
|
844
844
|
this.__homeySocket.once('connect_error', err => {
|
|
845
845
|
this.__debug(`SocketIOClient.Namespace[${namespace}].onConnectError`, err.message);
|
|
846
|
-
|
|
846
|
+
if (err) {
|
|
847
|
+
if (err instanceof Error) {
|
|
848
|
+
return reject(err);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// .statusCode for homey-core .code for homey-client.
|
|
852
|
+
if (typeof err === 'object') {
|
|
853
|
+
return reject(new HomeyAPIError({ error_description: err.message }, err.statusCode || err.code));
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
return reject(new Error(String(err)));
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
reject(new Error(`Unknown error connecting to namespace ${namespace}.`));
|
|
847
860
|
});
|
|
848
861
|
|
|
849
862
|
this.__homeySocket.on('disconnect', reason => {
|
|
@@ -875,17 +888,26 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
875
888
|
homeyId: this.id,
|
|
876
889
|
},
|
|
877
890
|
(err, result) => {
|
|
878
|
-
if (err) {
|
|
879
|
-
if (err instanceof Error) {
|
|
880
|
-
return reject(err);
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
// .statusCode for homey-core .code for homey-client.
|
|
891
|
+
if (err != null) {
|
|
884
892
|
if (typeof err === 'object') {
|
|
885
|
-
|
|
893
|
+
err = new HomeyAPIError(
|
|
894
|
+
{
|
|
895
|
+
stack: err.stack,
|
|
896
|
+
error: err.error,
|
|
897
|
+
error_description: err.error_description,
|
|
898
|
+
},
|
|
899
|
+
err.statusCode || err.code || 500
|
|
900
|
+
);
|
|
901
|
+
} else if (typeof err === 'string') {
|
|
902
|
+
err = new HomeyAPIError(
|
|
903
|
+
{
|
|
904
|
+
error: err,
|
|
905
|
+
},
|
|
906
|
+
500
|
|
907
|
+
);
|
|
886
908
|
}
|
|
887
909
|
|
|
888
|
-
return reject(
|
|
910
|
+
return reject(err);
|
|
889
911
|
}
|
|
890
912
|
|
|
891
913
|
return resolve(result);
|