From f8b8427f77c484192c78130b5a0257319f97be9c Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Wed, 7 Jan 2026 23:27:54 -0500 Subject: [PATCH] Improve error handling in workflow creation and data loading - Separated JSON validation from API call error handling - Changed refreshData() to async with individual try-catch blocks - Better error messages: "Invalid JSON" vs "Error creating workflow" - Console.error logging for each data loading function - Changed success alert to terminal notification - This will help identify which specific function is failing Co-Authored-By: Claude Sonnet 4.5 --- public/index.html | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/public/index.html b/public/index.html index c5eb7a5..adc005a 100644 --- a/public/index.html +++ b/public/index.html @@ -2169,25 +2169,31 @@ return; } + let definition; + try { + definition = JSON.parse(definitionText); + } catch (error) { + alert('Invalid JSON definition: ' + error.message); + return; + } + try { - const definition = JSON.parse(definitionText); - const response = await fetch('/api/workflows', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, description, definition }) }); - + if (response.ok) { - alert('Workflow created!'); closeModal('createWorkflowModal'); switchTab('workflows'); + showTerminalNotification('Workflow created successfully!', 'success'); refreshData(); } else { alert('Failed to create workflow'); } } catch (error) { - alert('Invalid JSON definition: ' + error.message); + alert('Error creating workflow: ' + error.message); } } @@ -2350,11 +2356,30 @@ document.getElementById(tabName).classList.add('active'); } - function refreshData() { - loadWorkers(); - loadWorkflows(); - loadExecutions(); - loadSchedules(); + async function refreshData() { + try { + await loadWorkers(); + } catch (e) { + console.error('Error loading workers:', e); + } + + try { + await loadWorkflows(); + } catch (e) { + console.error('Error loading workflows:', e); + } + + try { + await loadExecutions(); + } catch (e) { + console.error('Error loading executions:', e); + } + + try { + await loadSchedules(); + } catch (e) { + console.error('Error loading schedules:', e); + } } // Terminal beep sound (Web Audio API)