diff --git a/custom/JobInfoPopup.vue b/custom/JobInfoPopup.vue index e72bbc5..29cd7db 100644 --- a/custom/JobInfoPopup.vue +++ b/custom/JobInfoPopup.vue @@ -67,6 +67,7 @@ import { getTimeAgoString, callAdminForthApi, getCustomComponent} from '@/utils' import { useI18n } from 'vue-i18n'; import StateToIcon from './StateToIcon.vue'; import { useAdminforth } from '@/adminforth'; +import { watch } from 'vue'; const { t } = useI18n(); @@ -133,6 +134,19 @@ async function getJobTasks(limit: number = 10, offset: number = 0): Promise<{sta } } +watch( + () => props.job.state?.error, + (error) => { + if (error) { + adminforth.alert({ + message: error, + variant: 'danger', + }); + } + }, + { immediate: true } +); + \ No newline at end of file diff --git a/index.ts b/index.ts index f42cc1f..c490b6e 100644 --- a/index.ts +++ b/index.ts @@ -279,7 +279,9 @@ export default class BackgroundJobsPlugin extends AdminForthPlugin { await this.setLevelDbTaskStatusField(jobLevelDb, taskIndex.toString(), 'DONE'); this.adminforth.websocket.publish(`/background-jobs-task-update/${jobId}`, { taskIndex, status: "DONE" }); } catch (error) { - afLogger.error(`Error in handling task ${taskIndex} of job ${jobId}: ${error}`, ); + const errorMessage = error?.message || 'Unknown error'; + afLogger.error(`Error in handling task ${taskIndex} of job ${jobId}: ${errorMessage}`, ); + await this.setJobField(jobId, 'error', errorMessage); await this.setLevelDbTaskStatusField(jobLevelDb, taskIndex.toString(), 'FAILED'); this.adminforth.websocket.publish(`/background-jobs-task-update/${jobId}`, { taskIndex, status: "FAILED" }); failedTasks++;