From 87d57d62f8bac9106a893a28ecd3f5bba0e1bb44 Mon Sep 17 00:00:00 2001 From: dancode-188 Date: Sat, 27 Dec 2025 22:23:58 +0300 Subject: [PATCH] fix: throw error instead of silent return in cancelExecution, fixes #11 The cancelExecution method would silently return when an execution wasn't found or wasn't in running status, providing no feedback to the caller. Changed to throw descriptive errors: - Execution not found: throws with execution ID - Wrong status: throws with current status This gives callers proper error handling instead of silent failures. Note: Cancellation persistence (#13) is already handled by the existing db.chainExecutions.update() call at lines 324-328. --- src/lib/chain-service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/chain-service.ts b/src/lib/chain-service.ts index 3a703a0..b6666c2 100644 --- a/src/lib/chain-service.ts +++ b/src/lib/chain-service.ts @@ -306,7 +306,12 @@ class ChainService { */ async cancelExecution(executionId: string): Promise { const execution = await this.getExecution(executionId); - if (!execution || execution.status !== 'running') return; + if (!execution) { + throw new Error(`Execution ${executionId} not found`); + } + if (execution.status !== 'running') { + throw new Error(`Cannot cancel execution with status: ${execution.status}`); + } execution.status = 'cancelled'; execution.completedAt = new Date();