From d563e42a2fd716d96771e2506ee5b31ae98d4191 Mon Sep 17 00:00:00 2001 From: Alfie Brooks Date: Sat, 23 Dec 2023 00:35:07 +0000 Subject: [PATCH] fix: uncaught exception for openApp when app not installed (#302) --- src/samsung.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/samsung.ts b/src/samsung.ts index ad5b59b..02eb27f 100644 --- a/src/samsung.ts +++ b/src/samsung.ts @@ -228,10 +228,12 @@ class Samsung { if (!app) { this.LOGGER.error('This APP is not installed', { appId, app }, 'openApp getAppsFromTV') - throw new Error('This APP is not installed') + if (done) { + done(new Error('This APP is not installed'), null); + } + } else { + this._send(getMsgLaunchApp(app), done) } - - this._send(getMsgLaunchApp(app), done) }) } @@ -545,11 +547,9 @@ class Samsung { } private _getWSUrl() { - return `${this.PORT === 8001 ? 'ws' : 'wss'}://${this.IP}:${ - this.PORT - }/api/v2/channels/samsung.remote.control?name=${this.NAME_APP}${ - this.TOKEN !== '' ? `&token=${this.TOKEN}` : '' - }` + return `${this.PORT === 8001 ? 'ws' : 'wss'}://${this.IP}:${this.PORT + }/api/v2/channels/samsung.remote.control?name=${this.NAME_APP}${this.TOKEN !== '' ? `&token=${this.TOKEN}` : '' + }` } }