mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
Fix/986 (#990)
* throw new NonFatalTask error on play file not found * linting * make SpeechCredentialError subclass of NonFatalTask error * cleanup * Update action-hook-delay.js * bump fsmrf version * linting and package-lock * Update package-lock.json * update error * only throw on fs error "File not found" * add alert * update time-series dep * Update package-lock.json * linting * Update play.js * remove stack trace from error message * fix error formatting
This commit is contained in:
@@ -33,7 +33,7 @@ const BackgroundTaskManager = require('../utils/background-task-manager');
|
||||
const dbUtils = require('../utils/db-utils');
|
||||
const BADPRECONDITIONS = 'preconditions not met';
|
||||
const CALLER_CANCELLED_ERR_MSG = 'Response not sent due to unknown transaction';
|
||||
|
||||
const { NonFatalTaskError} = require('../utils/error');
|
||||
const sqlRetrieveQueueEventHook = `SELECT * FROM webhooks
|
||||
WHERE webhook_sid =
|
||||
(
|
||||
@@ -1092,6 +1092,8 @@ class CallSession extends Emitter {
|
||||
this.currentTask = null;
|
||||
if (err.message?.includes(BADPRECONDITIONS)) {
|
||||
this.logger.info(`CallSession:exec task #${stackNum}:${taskNum}: ${task.name}: ${err.message}`);
|
||||
} else if (err instanceof NonFatalTaskError) {
|
||||
this.logger.error(err, `Error executing task #${stackNum}:${taskNum}: ${task.name}`);
|
||||
}
|
||||
else {
|
||||
this.logger.error(err, `Error executing task #${stackNum}:${taskNum}: ${task.name}`);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const Task = require('./task');
|
||||
const {TaskName, TaskPreconditions} = require('../utils/constants');
|
||||
const { PlayFileNotFoundError } = require('../utils/error');
|
||||
|
||||
class TaskPlay extends Task {
|
||||
constructor(logger, opts) {
|
||||
@@ -66,8 +67,20 @@ class TaskPlay extends Task {
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (timeout) clearTimeout(timeout);
|
||||
this.logger.info(err, `TaskPlay:exec - error playing ${this.url}`);
|
||||
this.logger.info(`TaskPlay:exec - error playing ${this.url}: ${err.message}`);
|
||||
this.playComplete = true;
|
||||
if (err.message === 'File Not Found') {
|
||||
const {writeAlerts, AlertType} = cs.srf.locals;
|
||||
await this.performAction({status: 'fail', reason: 'playFailed'}, !(this.parentTask || cs.isConfirmCallSession));
|
||||
this.emit('playDone');
|
||||
writeAlerts({
|
||||
account_sid: cs.accountSid,
|
||||
alert_type: AlertType.PLAY_FILENOTFOUND,
|
||||
url: this.url,
|
||||
target_sid: cs.callSid
|
||||
});
|
||||
throw new PlayFileNotFoundError(this.url);
|
||||
}
|
||||
}
|
||||
this.emit('playDone');
|
||||
}
|
||||
|
||||
@@ -126,7 +126,12 @@ class ActionHookDelayProcessor extends Emitter {
|
||||
try {
|
||||
this._taskInProgress = makeTask(this.logger, t[0]);
|
||||
this._taskInProgress.disableTracing = true;
|
||||
this._taskInProgress.exec(this.cs, {ep: this.ep});
|
||||
this._taskInProgress.exec(this.cs, {ep: this.ep}).catch((err) => {
|
||||
this.logger.info(`ActionHookDelayProcessor#_onNoResponseTimer: error playing file: ${err.message}`);
|
||||
this._taskInProgress = null;
|
||||
this.ep.removeAllListeners('playback-start');
|
||||
this.ep.removeAllListeners('playback-stop');
|
||||
});
|
||||
} catch (err) {
|
||||
this.logger.info(err, 'ActionHookDelayProcessor#_onNoResponseTimer: error starting action');
|
||||
this._taskInProgress = null;
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
class SpeechCredentialError extends Error {
|
||||
class NonFatalTaskError extends Error {
|
||||
constructor(msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
class SpeechCredentialError extends NonFatalTaskError {
|
||||
constructor(msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
class PlayFileNotFoundError extends NonFatalTaskError {
|
||||
constructor(url) {
|
||||
super('File not found');
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
SpeechCredentialError
|
||||
SpeechCredentialError,
|
||||
NonFatalTaskError,
|
||||
PlayFileNotFoundError
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user