Skip to content

Commit 869c95a

Browse files
rosen-vladimirovDimitar Kerezov
authored andcommitted
Rename error event to liveSyncError
Rename the error event to liveSyncError as EventEmitter expects instance of Error when event named `error` is raised. So it fails to parse our object. Also it automatically raised Uncaught error in CLI when noone has added a handler for error event:`Uncaught, unspecified "error" event. ([object Object])`. Fix incorrect message in an error where deviceIdentifier was not printed correctly.
1 parent 3a38e78 commit 869c95a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

PublicAPI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ tns.liveSyncService.on("liveSyncStopped", data => {
667667
});
668668
```
669669
670-
* error - raised whenever an error is detected during LiveSync operation. The event is raised for specific device. Once an error is detected, the event will be raised and the LiveSync operation will be stopped for this device, i.e. `liveSyncStopped` event will be raised for it. The event is raised with the following data:
670+
* liveSyncError - raised whenever an error is detected during LiveSync operation. The event is raised for specific device. Once an error is detected, the event will be raised and the LiveSync operation will be stopped for this device, i.e. `liveSyncStopped` event will be raised for it. The event is raised with the following data:
671671
```TypeScript
672672
{
673673
projectDir: string;
@@ -679,7 +679,7 @@ tns.liveSyncService.on("liveSyncStopped", data => {
679679
680680
Example:
681681
```JavaScript
682-
tns.liveSyncService.on("error", data => {
682+
tns.liveSyncService.on("liveSyncError", data => {
683683
console.log(`Error detected during LiveSync on ${data.deviceIdentifier} for ${data.projectDir}. Error: ${err.message}.`);
684684
});
685685
```

lib/services/livesync/livesync-service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { hook } from "../../common/helpers";
66

77
const LiveSyncEvents = {
88
liveSyncStopped: "liveSyncStopped",
9-
liveSyncError: "error",
9+
// In case we name it error, EventEmitter expects instance of Error to be raised and will also raise uncaught exception in case there's no handler
10+
liveSyncError: "liveSyncError",
1011
liveSyncExecuted: "liveSyncExecuted",
1112
liveSyncStarted: "liveSyncStarted",
1213
liveSyncNotification: "notify"
@@ -209,7 +210,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
209210
});
210211
await this.refreshApplication(projectData, liveSyncResultInfo);
211212
} catch (err) {
212-
this.$logger.warn(`Unable to apply changes on device: ${err.deviceIdentifier}. Error is: ${err.message}.`);
213+
this.$logger.warn(`Unable to apply changes on device: ${device.deviceInfo.identifier}. Error is: ${err.message}.`);
213214

214215
this.emit(LiveSyncEvents.liveSyncError, {
215216
error: err,

0 commit comments

Comments
 (0)