From 284226166ecf6415908f6b80b1b999ba9c1f01ce Mon Sep 17 00:00:00 2001 From: Vijay <74645268+vijaysingh2219@users.noreply.github.com> Date: Thu, 7 Mar 2024 21:32:46 +0530 Subject: [PATCH] Modified the try-catch block --- src/runners/runner.ts | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/runners/runner.ts b/src/runners/runner.ts index eb5b57f..c351174 100644 --- a/src/runners/runner.ts +++ b/src/runners/runner.ts @@ -88,22 +88,16 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt if (!output || (!output.stream?.length && !output.embeds.length)) { throw new NotFoundError('No streams found'); } - } catch (err) { - if (err instanceof NotFoundError) { - ops.events?.update?.({ - id: source.id, - percentage: 100, - status: 'notfound', - reason: err.message, - }); - continue; - } - ops.events?.update?.({ + } catch (error) { + const updateParams: UpdateEvent = { id: source.id, percentage: 100, - status: 'failure', - error: err, - }); + status: error instanceof NotFoundError ? 'notfound' : 'failure', + reason: error instanceof NotFoundError ? error.message : undefined, + error: error instanceof NotFoundError ? undefined : error, + }; + + ops.events?.update?.(updateParams); continue; } if (!output) throw new Error('Invalid media type'); @@ -161,16 +155,11 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt percentage: 100, status: error instanceof NotFoundError ? 'notfound' : 'failure', reason: error instanceof NotFoundError ? error.message : undefined, - error, + error: error instanceof NotFoundError ? undefined : error, }; ops.events?.update?.(updateParams); - - if (error instanceof NotFoundError) { - continue; - } - - throw error; + continue; } return {