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:
Sam Machin
2025-04-17 12:43:22 +01:00
committed by GitHub
parent 87195b6444
commit 4e74bab728

View File

@@ -39,6 +39,10 @@ class TaskLlmUltravox_S2S extends Task {
this.eventHook = this.data.eventHook;
this.toolHook = this.data.toolHook;
this.results = {
completionReason: 'normal conversation end'
};
/**
* only one of these will have items,
* if includeEvents, then these are the events to include
@@ -86,7 +90,7 @@ class TaskLlmUltravox_S2S extends Task {
const data = await body.json();
if (statusCode !== 201 || !data?.joinUrl) {
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');
return data;
@@ -106,12 +110,11 @@ class TaskLlmUltravox_S2S extends Task {
async _startListening(cs, 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 {
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];
await this._api(ep, args);
// Notify the application that the session has been created with detail information
@@ -121,6 +124,7 @@ class TaskLlmUltravox_S2S extends Task {
});
} catch (err) {
this.logger.info({err}, 'TaskLlmUltraVox_S2S:_startListening - Error sending createCall');
this.results = {completionReason: `connection failure - ${err}`};
this.notifyTaskDone();
}
}