mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-02-14 18:30:59 +00:00
handle errors in createing call (#1164)
* move createCall into the try/catch and add a completionReason to results for errors * add default completionReason fixes #1165 * lint
This commit is contained in:
@@ -39,6 +39,10 @@ class TaskLlmUltravox_S2S extends Task {
|
|||||||
this.eventHook = this.data.eventHook;
|
this.eventHook = this.data.eventHook;
|
||||||
this.toolHook = this.data.toolHook;
|
this.toolHook = this.data.toolHook;
|
||||||
|
|
||||||
|
this.results = {
|
||||||
|
completionReason: 'normal conversation end'
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* only one of these will have items,
|
* only one of these will have items,
|
||||||
* if includeEvents, then these are the events to include
|
* if includeEvents, then these are the events to include
|
||||||
@@ -86,7 +90,7 @@ class TaskLlmUltravox_S2S extends Task {
|
|||||||
const data = await body.json();
|
const data = await body.json();
|
||||||
if (statusCode !== 201 || !data?.joinUrl) {
|
if (statusCode !== 201 || !data?.joinUrl) {
|
||||||
this.logger.info({statusCode, data}, 'Ultravox Error registering call');
|
this.logger.info({statusCode, data}, 'Ultravox Error registering call');
|
||||||
throw new Error(`Ultravox Error registering call: ${data.message}`);
|
throw new Error(`Ultravox Error registering call:${statusCode} - ${data.detail}`);
|
||||||
}
|
}
|
||||||
this.logger.debug({joinUrl: data.joinUrl}, 'Ultravox Call registered');
|
this.logger.debug({joinUrl: data.joinUrl}, 'Ultravox Call registered');
|
||||||
return data;
|
return data;
|
||||||
@@ -106,12 +110,11 @@ class TaskLlmUltravox_S2S extends Task {
|
|||||||
async _startListening(cs, ep) {
|
async _startListening(cs, ep) {
|
||||||
this._registerHandlers(ep);
|
this._registerHandlers(ep);
|
||||||
|
|
||||||
const data = await this.createCall();
|
|
||||||
const {joinUrl} = data;
|
|
||||||
// split the joinUrl into host and path
|
|
||||||
const {host, pathname, search} = new URL(joinUrl);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const data = await this.createCall();
|
||||||
|
const {joinUrl} = data;
|
||||||
|
// split the joinUrl into host and path
|
||||||
|
const {host, pathname, search} = new URL(joinUrl);
|
||||||
const args = [ep.uuid, 'session.create', host, pathname + search];
|
const args = [ep.uuid, 'session.create', host, pathname + search];
|
||||||
await this._api(ep, args);
|
await this._api(ep, args);
|
||||||
// Notify the application that the session has been created with detail information
|
// Notify the application that the session has been created with detail information
|
||||||
@@ -121,6 +124,7 @@ class TaskLlmUltravox_S2S extends Task {
|
|||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.info({err}, 'TaskLlmUltraVox_S2S:_startListening - Error sending createCall');
|
this.logger.info({err}, 'TaskLlmUltraVox_S2S:_startListening - Error sending createCall');
|
||||||
|
this.results = {completionReason: `connection failure - ${err}`};
|
||||||
this.notifyTaskDone();
|
this.notifyTaskDone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user