mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-07-14 11:17:35 +00:00
## Summary - Add `errorMessage` and `executionError` getters to `TaskItemImpl` that extract error info from status messages - Update `useJobErrorReporting` composable to use these getters instead of standalone function - Remove the standalone `extractExecutionError` function This encapsulates error extraction within `TaskItemImpl`, preparing for the Jobs API migration where the underlying data format will change but the getter interface will remain stable. ## Test plan - [x] All existing tests pass - [x] New tests added for `TaskItemImpl.errorMessage` and `TaskItemImpl.executionError` getters - [x] TypeScript, lint, and knip checks pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7650-refactor-encapsulate-error-extraction-in-TaskItemImpl-getters-2ce6d73d365081caae33dcc7e1e07720) by [Unito](https://www.unito.io) --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Christian Byrne <cbyrne@comfy.org>
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import { computed } from 'vue'
|
|
import type { ComputedRef } from 'vue'
|
|
|
|
import type { ExecutionErrorDialogInput } from '@/services/dialogService'
|
|
import type { TaskItemImpl } from '@/stores/queueStore'
|
|
|
|
type CopyHandler = (value: string) => void | Promise<void>
|
|
|
|
export type JobErrorDialogService = {
|
|
showExecutionErrorDialog: (executionError: ExecutionErrorDialogInput) => void
|
|
showErrorDialog: (
|
|
error: Error,
|
|
options?: {
|
|
reportType?: string
|
|
[key: string]: unknown
|
|
}
|
|
) => void
|
|
}
|
|
|
|
type UseJobErrorReportingOptions = {
|
|
taskForJob: ComputedRef<TaskItemImpl | null>
|
|
copyToClipboard: CopyHandler
|
|
dialog: JobErrorDialogService
|
|
}
|
|
|
|
export const useJobErrorReporting = ({
|
|
taskForJob,
|
|
copyToClipboard,
|
|
dialog
|
|
}: UseJobErrorReportingOptions) => {
|
|
const errorMessageValue = computed(() => taskForJob.value?.errorMessage ?? '')
|
|
|
|
const copyErrorMessage = () => {
|
|
if (errorMessageValue.value) {
|
|
void copyToClipboard(errorMessageValue.value)
|
|
}
|
|
}
|
|
|
|
const reportJobError = () => {
|
|
const executionError = taskForJob.value?.executionError
|
|
if (executionError) {
|
|
dialog.showExecutionErrorDialog(executionError)
|
|
return
|
|
}
|
|
|
|
if (errorMessageValue.value) {
|
|
dialog.showErrorDialog(new Error(errorMessageValue.value), {
|
|
reportType: 'queueJobError'
|
|
})
|
|
}
|
|
}
|
|
|
|
return {
|
|
errorMessageValue,
|
|
copyErrorMessage,
|
|
reportJobError
|
|
}
|
|
}
|