From 1984b6d3ea6c8906257fe8a5cacf4493a8559213 Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Thu, 20 Nov 2025 19:22:28 +0700 Subject: [PATCH] allow say verb failed as NonFatalTaskError for File Not Found (#1443) * allow say verb failed as NonFatalTaskError for File Not Found * wip --- lib/tasks/say.js | 19 ++++++++++++++----- lib/utils/constants.json | 5 ++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/tasks/say.js b/lib/tasks/say.js index 44709172..e29f7a5d 100644 --- a/lib/tasks/say.js +++ b/lib/tasks/say.js @@ -2,8 +2,9 @@ const assert = require('assert'); const TtsTask = require('./tts-task'); const {TaskName, TaskPreconditions} = require('../utils/constants'); const pollySSMLSplit = require('polly-ssml-split'); -const { SpeechCredentialError } = require('../utils/error'); +const { SpeechCredentialError, NonFatalTaskError } = require('../utils/error'); const { sleepFor } = require('../utils/helpers'); +const { NON_FANTAL_ERRORS } = require('../utils/constants.json'); /** * Discard unmatching responses: @@ -402,11 +403,19 @@ class TaskSay extends TtsTask { this._playResolve = resolve; this._playReject = reject; }); - const r = await ep.play(filename); - this.logger.debug({r}, 'Say:exec play result'); - if (r.playbackSeconds == null && r.playbackMilliseconds == null && r.playbackLastOffsetPos == null) { - this._playReject(new Error('Playback failed to start')); + try { + const r = await ep.play(filename); + this.logger.debug({r}, 'Say:exec play result'); + if (r.playbackSeconds == null && r.playbackMilliseconds == null && r.playbackLastOffsetPos == null) { + this._playReject(new Error('Playback failed to start')); + } + } catch (err) { + if (NON_FANTAL_ERRORS.includes(err.message)) { + throw new NonFatalTaskError(err.message); + } + throw err; } + try { // wait for playback-stop event received to confirm if the playback is successful await this._playPromise; diff --git a/lib/utils/constants.json b/lib/utils/constants.json index e6e3176d..f771d8d7 100644 --- a/lib/utils/constants.json +++ b/lib/utils/constants.json @@ -356,5 +356,8 @@ "WS_CLOSE_CODES": { "NormalClosure": 1000, "GoingAway": 1001 - } + }, + "NON_FANTAL_ERRORS": [ + "File Not Found" + ] }