LCOV - code coverage report
Current view: top level - src/components/queue/job - useJobErrorReporting.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 38.5 % 13 5
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { computed } from 'vue'
       2              : import type { ComputedRef } from 'vue'
       3              : 
       4              : import type { ExecutionErrorDialogInput } from '@/services/dialogService'
       5              : import type { TaskItemImpl } from '@/stores/queueStore'
       6              : 
       7              : type CopyHandler = (value: string) => void | Promise<unknown>
       8              : 
       9              : export type JobErrorDialogService = {
      10              :   showExecutionErrorDialog: (executionError: ExecutionErrorDialogInput) => void
      11              :   showErrorDialog: (
      12              :     error: Error,
      13              :     options?: {
      14              :       reportType?: string
      15              :       [key: string]: unknown
      16              :     }
      17              :   ) => void
      18              : }
      19              : 
      20              : type UseJobErrorReportingOptions = {
      21              :   taskForJob: ComputedRef<TaskItemImpl | null>
      22              :   copyToClipboard: CopyHandler
      23              :   dialog: JobErrorDialogService
      24              : }
      25              : 
      26         2355 : export const useJobErrorReporting = ({
      27              :   taskForJob,
      28              :   copyToClipboard,
      29              :   dialog
      30              : }: UseJobErrorReportingOptions) => {
      31            1 :   const errorMessageValue = computed(() => taskForJob.value?.errorMessage ?? '')
      32              : 
      33            1 :   const copyErrorMessage = () => {
      34            0 :     if (errorMessageValue.value) {
      35            0 :       void copyToClipboard(errorMessageValue.value)
      36              :     }
      37              :   }
      38              : 
      39            1 :   const reportJobError = () => {
      40            0 :     const executionError = taskForJob.value?.executionError
      41            0 :     if (executionError) {
      42            0 :       dialog.showExecutionErrorDialog(executionError)
      43            0 :       return
      44              :     }
      45              : 
      46            0 :     if (errorMessageValue.value) {
      47            0 :       dialog.showErrorDialog(new Error(errorMessageValue.value), {
      48              :         reportType: 'queueJobError'
      49              :       })
      50              :     }
      51              :   }
      52              : 
      53            1 :   return {
      54              :     errorMessageValue,
      55              :     copyErrorMessage,
      56              :     reportJobError
      57              :   }
      58              : }
        

Generated by: LCOV version 2.0-1