mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
send error notification over websocket if tts fails
This commit is contained in:
@@ -51,6 +51,7 @@ class TaskSay extends Task {
|
|||||||
alert_type: AlertType.TTS_NOT_PROVISIONED,
|
alert_type: AlertType.TTS_NOT_PROVISIONED,
|
||||||
vendor
|
vendor
|
||||||
}).catch((err) => this.logger.info({err}, 'Error generating alert for no tts'));
|
}).catch((err) => this.logger.info({err}, 'Error generating alert for no tts'));
|
||||||
|
this.notifyError(`No speech credentials have been provisioned for ${vendor}`);
|
||||||
throw new Error('no provisioned speech credentials for TTS');
|
throw new Error('no provisioned speech credentials for TTS');
|
||||||
}
|
}
|
||||||
// synthesize all of the text elements
|
// synthesize all of the text elements
|
||||||
@@ -96,6 +97,7 @@ class TaskSay extends Task {
|
|||||||
vendor,
|
vendor,
|
||||||
detail: err.message
|
detail: err.message
|
||||||
}).catch((err) => this.logger.info({err}, 'Error generating alert for tts failure'));
|
}).catch((err) => this.logger.info({err}, 'Error generating alert for tts failure'));
|
||||||
|
this.notifyError(err.message || err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -137,6 +137,12 @@ class Task extends Emitter {
|
|||||||
return this.callSession.normalizeUrl(url, method, auth);
|
return this.callSession.normalizeUrl(url, method, auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notifyError(errMsg) {
|
||||||
|
const params = {error: errMsg, ...this.cs.callInfo.toJSON()};
|
||||||
|
this.cs.requestor.request('jambonz:error', '/error', params)
|
||||||
|
.catch((err) => this.logger.info({err}, 'Task:notifyError error sending error'));
|
||||||
|
}
|
||||||
|
|
||||||
async performAction(results, expectResponse = true) {
|
async performAction(results, expectResponse = true) {
|
||||||
if (this.actionHook) {
|
if (this.actionHook) {
|
||||||
const params = results ? Object.assign(results, this.cs.callInfo.toJSON()) : this.cs.callInfo.toJSON();
|
const params = results ? Object.assign(results, this.cs.callInfo.toJSON()) : this.cs.callInfo.toJSON();
|
||||||
|
|||||||
@@ -50,7 +50,11 @@ class HttpRequestor extends BaseRequestor {
|
|||||||
* @param {object} [params] - request parameters
|
* @param {object} [params] - request parameters
|
||||||
*/
|
*/
|
||||||
async request(type, hook, params, httpHeaders = {}) {
|
async request(type, hook, params, httpHeaders = {}) {
|
||||||
|
/* jambonz:error only sent over ws */
|
||||||
|
if (type === 'jambonz:error') return;
|
||||||
|
|
||||||
assert(HookMsgTypes.includes(type));
|
assert(HookMsgTypes.includes(type));
|
||||||
|
|
||||||
const payload = params ? snakeCaseKeys(params, ['customerData', 'sip']) : null;
|
const payload = params ? snakeCaseKeys(params, ['customerData', 'sip']) : null;
|
||||||
const url = hook.url || hook;
|
const url = hook.url || hook;
|
||||||
const method = hook.method || 'POST';
|
const method = hook.method || 'POST';
|
||||||
|
|||||||
Reference in New Issue
Block a user