mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 22:37:32 +00:00
* [refactor] Move update-related functionality to platform/updates domain Reorganizes release management, version compatibility, and notification functionality following Domain-Driven Design principles, mirroring VSCode's architecture pattern. - Move releaseService.ts to platform/updates/common/ - Move releaseStore.ts to platform/updates/common/ - Move versionCompatibilityStore.ts to platform/updates/common/ - Move useFrontendVersionMismatchWarning.ts to platform/updates/common/ - Move toastStore.ts to platform/updates/common/ - Move ReleaseNotificationToast.vue to platform/updates/components/ - Move WhatsNewPopup.vue to platform/updates/components/ - Update 25+ import paths across codebase and tests This creates a cohesive "updates" domain containing all functionality related to software updates, version checking, release notifications, and user communication about application state changes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix imports --------- Co-authored-by: Claude <noreply@anthropic.com>
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { t } from '@/i18n'
|
|
import { useToastStore } from '@/platform/updates/common/toastStore'
|
|
|
|
export function useErrorHandling() {
|
|
const toast = useToastStore()
|
|
const toastErrorHandler = (error: unknown) => {
|
|
toast.add({
|
|
severity: 'error',
|
|
summary: t('g.error'),
|
|
detail: error instanceof Error ? error.message : t('g.unknownError')
|
|
})
|
|
console.error(error)
|
|
}
|
|
|
|
const wrapWithErrorHandling =
|
|
<TArgs extends any[], TReturn>(
|
|
action: (...args: TArgs) => TReturn,
|
|
errorHandler?: (error: any) => void,
|
|
finallyHandler?: () => void
|
|
) =>
|
|
(...args: TArgs): TReturn | undefined => {
|
|
try {
|
|
return action(...args)
|
|
} catch (e) {
|
|
;(errorHandler ?? toastErrorHandler)(e)
|
|
} finally {
|
|
finallyHandler?.()
|
|
}
|
|
}
|
|
|
|
const wrapWithErrorHandlingAsync =
|
|
<TArgs extends any[], TReturn>(
|
|
action: (...args: TArgs) => Promise<TReturn> | TReturn,
|
|
errorHandler?: (error: any) => void,
|
|
finallyHandler?: () => void
|
|
) =>
|
|
async (...args: TArgs): Promise<TReturn | undefined> => {
|
|
try {
|
|
return await action(...args)
|
|
} catch (e) {
|
|
;(errorHandler ?? toastErrorHandler)(e)
|
|
} finally {
|
|
finallyHandler?.()
|
|
}
|
|
}
|
|
|
|
return {
|
|
wrapWithErrorHandling,
|
|
wrapWithErrorHandlingAsync,
|
|
toastErrorHandler
|
|
}
|
|
}
|