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 <noreply@anthropic.com>
This commit is contained in:
@@ -2169,9 +2169,15 @@
|
||||
return;
|
||||
}
|
||||
|
||||
let definition;
|
||||
try {
|
||||
const definition = JSON.parse(definitionText);
|
||||
definition = JSON.parse(definitionText);
|
||||
} catch (error) {
|
||||
alert('Invalid JSON definition: ' + error.message);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/workflows', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -2179,15 +2185,15 @@
|
||||
});
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user