Add try-catch to async IIFEs to prevent unhandled rejections

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 18:11:27 +08:00
parent ede7becb3a
commit 7d5918837b
5 changed files with 224 additions and 204 deletions

View File

@@ -905,51 +905,54 @@ function getAvgWaitingTimeLineChart(chartData, content, yUnit) {
// Created logic
(async () => {
isLoading.value = true;
const routeParams = route.params;
const isCheckPage = route.name.includes('Check');
const type = routeParams.type;
const file = route.meta.file;
let id;
try {
const routeParams = route.params;
const isCheckPage = route.name.includes('Check');
const type = routeParams.type;
const file = route.meta.file;
let id;
if(!isCheckPage) {
id = routeParams.fileId;
} else {
id = file.parent.id;
}
if(!isCheckPage) {
id = routeParams.fileId;
} else {
id = file.parent.id;
}
// 取得 Performance Data
await performanceStore.getPerformance(type, id);
if(!performanceData.value?.time) {
// 取得 Performance Data
await performanceStore.getPerformance(type, id);
if(!performanceData.value?.time) {
return;
}
avgProcessTimeByTaskHeight.value = getHorizontalBarHeight(performanceData.value.time.avg_process_time_by_task);
if(performanceData.value.time.avg_waiting_time_by_edge !== null) {
avgWaitingTimeByEdgeHeight.value = getHorizontalBarHeight(performanceData.value.time.avg_waiting_time_by_edge);
}
casesByTaskHeight.value = getHorizontalBarHeight(performanceData.value.freq.cases_by_task);
// create chart
[avgCycleTimeData.value, avgCycleTimeOptions.value] = getExplicitDeclaredLineChart(performanceData.value.time.avg_cycle_time,
contentData.avgCycleTime, 'date');
[avgCycleEfficiencyData.value, avgCycleEfficiencyOptions.value] = getBarChart(
performanceData.value.time.avg_cycle_efficiency, contentData.avgCycleEfficiency);
[avgProcessTimeData.value, avgProcessTimeOptions.value] = getExplicitDeclaredLineChart(performanceData.value.time.avg_process_time,
contentData.avgProcessTime, 'date');
[avgProcessTimeByTaskData.value, avgProcessTimeByTaskOptions.value] = getHorizontalBarChart(
performanceData.value.time.avg_process_time_by_task, contentData.avgProcessTimeByTask, true, 'date');
[avgWaitingTimeData.value, avgWaitingTimeOptions.value] = getExplicitDeclaredLineChart(
performanceData.value.time.avg_waiting_time, contentData.avgWaitingTime, 'date');
if(performanceData.value.time.avg_waiting_time_by_edge !== null) {
[avgWaitingTimeByEdgeData.value, avgWaitingTimeByEdgeOptions.value] = getHorizontalBarChart(
performanceData.value.time.avg_waiting_time_by_edge, contentData.avgWaitingTimeByEdge, false, 'date');
} else {
[avgWaitingTimeByEdgeData.value, avgWaitingTimeByEdgeOptions.value] = [null, null]
}
[casesByTaskData.value, casesByTaskOptions.value] = getHorizontalBarChart(performanceData.value.freq.cases_by_task,
contentData.casesByTask, true, 'count');
} catch (error) {
console.error('Failed to initialize performance:', error);
} finally {
isLoading.value = false;
return;
}
avgProcessTimeByTaskHeight.value = getHorizontalBarHeight(performanceData.value.time.avg_process_time_by_task);
if(performanceData.value.time.avg_waiting_time_by_edge !== null) {
avgWaitingTimeByEdgeHeight.value = getHorizontalBarHeight(performanceData.value.time.avg_waiting_time_by_edge);
}
casesByTaskHeight.value = getHorizontalBarHeight(performanceData.value.freq.cases_by_task);
// create chart
[avgCycleTimeData.value, avgCycleTimeOptions.value] = getExplicitDeclaredLineChart(performanceData.value.time.avg_cycle_time,
contentData.avgCycleTime, 'date');
[avgCycleEfficiencyData.value, avgCycleEfficiencyOptions.value] = getBarChart(
performanceData.value.time.avg_cycle_efficiency, contentData.avgCycleEfficiency);
[avgProcessTimeData.value, avgProcessTimeOptions.value] = getExplicitDeclaredLineChart(performanceData.value.time.avg_process_time,
contentData.avgProcessTime, 'date');
[avgProcessTimeByTaskData.value, avgProcessTimeByTaskOptions.value] = getHorizontalBarChart(
performanceData.value.time.avg_process_time_by_task, contentData.avgProcessTimeByTask, true, 'date');
[avgWaitingTimeData.value, avgWaitingTimeOptions.value] = getExplicitDeclaredLineChart(
performanceData.value.time.avg_waiting_time, contentData.avgWaitingTime, 'date');
if(performanceData.value.time.avg_waiting_time_by_edge !== null) {
[avgWaitingTimeByEdgeData.value, avgWaitingTimeByEdgeOptions.value] = getHorizontalBarChart(
performanceData.value.time.avg_waiting_time_by_edge, contentData.avgWaitingTimeByEdge, false, 'date');
} else {
[avgWaitingTimeByEdgeData.value, avgWaitingTimeByEdgeOptions.value] = [null, null]
}
[casesByTaskData.value, casesByTaskOptions.value] = getHorizontalBarChart(performanceData.value.freq.cases_by_task,
contentData.casesByTask, true, 'count');
// 停止 loading
isLoading.value = false;
})();
</script>
<style scoped>