Prompt
Implement comprehensive error handling that covers prevention, recovery, and diagnosis:
- Prevent errors through thorough validation before enabling actions
- Validate that all required data exists before allowing operations
// Instead of just checking mime type and filename function isDownloadable(index, key) { const { mimeType, fileName } = binaryData[index][key]; return !!(mimeType && fileName && (binaryData[index][key].id || binaryData[index][key].data)); }
- Validate that all required data exists before allowing operations
- Ensure recovery by properly resetting state flags in finally blocks
- Don’t leave UI in disabled states after operations complete or fail
try { cancellingTestRun.value = true; await evaluationStore.cancelTestRun(workflowId, runId); } catch (error) { // Error handling } finally { cancellingTestRun.value = false; }
- Don’t leave UI in disabled states after operations complete or fail
- Enable diagnosis by preserving and exposing error details
- Log complete error objects, not just generic messages
} catch (error) { console.error(chalk.red(`An error occurred during the build process: ${error}`)); }
- Log complete error objects, not just generic messages
Each layer of error handling contributes to a more robust application that prevents user frustration and simplifies troubleshooting.