diff --git a/ui/src/components/access/AccessEditDrawer.tsx b/ui/src/components/access/AccessEditDrawer.tsx index 5c4db4cd..feb97cc6 100644 --- a/ui/src/components/access/AccessEditDrawer.tsx +++ b/ui/src/components/access/AccessEditDrawer.tsx @@ -11,7 +11,7 @@ import { type AccessModel } from "@/domain/access"; import { ACCESS_USAGES } from "@/domain/provider"; import { useTriggerElement, useZustandShallowSelector } from "@/hooks"; import { useAccessesStore } from "@/stores/access"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; import AccessForm, { type AccessFormModes, type AccessFormProps, type AccessFormUsages } from "./AccessForm"; @@ -97,7 +97,7 @@ const AccessEditDrawer = ({ afterSubmit, mode, data, loading, trigger, usage, .. afterSubmit?.(formValues); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; } finally { @@ -146,7 +146,7 @@ const AccessEditDrawer = ({ afterSubmit, mode, data, loading, trigger, usage, .. await testPushNotification({ provider: fieldProvider, accessId: data!.id }); message.success(t("common.text.operation_succeeded")); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } finally { setIsTesting(false); } diff --git a/ui/src/components/workflow/WorkflowRunDetail.tsx b/ui/src/components/workflow/WorkflowRunDetail.tsx index b6ba5fc6..860ef16e 100644 --- a/ui/src/components/workflow/WorkflowRunDetail.tsx +++ b/ui/src/components/workflow/WorkflowRunDetail.tsx @@ -17,7 +17,7 @@ import { listByWorkflowRunId as listCertificatesByWorkflowRunId } from "@/reposi import { listByWorkflowRunId as listLogsByWorkflowRunId } from "@/repository/workflowLog"; import { subscribe as subscribeWorkflowRun } from "@/repository/workflowRun"; import { mergeCls } from "@/utils/css"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; import WorkflowDesigner from "./designer/Designer"; import WorkflowToolbar from "./designer/Toolbar"; @@ -439,7 +439,7 @@ const WorkflowRunArtifacts = ({ runId }: { runId: string }) => { } console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; }, diff --git a/ui/src/components/workflow/designer/forms/BizApplyNodeConfigForm.tsx b/ui/src/components/workflow/designer/forms/BizApplyNodeConfigForm.tsx index 2d672d5c..42cd2fe5 100644 --- a/ui/src/components/workflow/designer/forms/BizApplyNodeConfigForm.tsx +++ b/ui/src/components/workflow/designer/forms/BizApplyNodeConfigForm.tsx @@ -23,7 +23,7 @@ import { type WorkflowNodeConfigForBizApply, defaultNodeConfigForBizApply } from import { useAntdForm, useZustandShallowSelector } from "@/hooks"; import { useAccessesStore } from "@/stores/access"; import { useContactEmailsStore } from "@/stores/settings"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; import { matchSearchOption } from "@/utils/search"; import { isDomain, isHostname } from "@/utils/validator"; @@ -232,7 +232,7 @@ const BizApplyNodeConfigForm = ({ node, ...props }: BizApplyNodeConfigFormProps) { name: "keyContent", value: value, - errors: [getErrMsg(err)], + errors: [unwrapErrMsg(err)], }, ]); } diff --git a/ui/src/components/workflow/designer/forms/BizUploadNodeConfigForm.tsx b/ui/src/components/workflow/designer/forms/BizUploadNodeConfigForm.tsx index 46c815e2..5e38be26 100644 --- a/ui/src/components/workflow/designer/forms/BizUploadNodeConfigForm.tsx +++ b/ui/src/components/workflow/designer/forms/BizUploadNodeConfigForm.tsx @@ -11,7 +11,7 @@ import Show from "@/components/Show"; import Tips from "@/components/Tips"; import { type WorkflowNodeConfigForBizUpload, defaultNodeConfigForBizUpload } from "@/domain/workflow"; import { useAntdForm } from "@/hooks"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; import { isUrlWithHttpOrHttps } from "@/utils/validator"; import { getSubjectAltNames as getX509SubjectAltNames } from "@/utils/x509"; @@ -80,7 +80,7 @@ const BizUploadNodeConfigForm = ({ node, ...props }: BizUploadNodeConfigFormProp { name: "certificate", value: value, - errors: [getErrMsg(err)], + errors: [unwrapErrMsg(err)], }, ]); } @@ -100,7 +100,7 @@ const BizUploadNodeConfigForm = ({ node, ...props }: BizUploadNodeConfigFormProp { name: "privateKey", value: value, - errors: [getErrMsg(err)], + errors: [unwrapErrMsg(err)], }, ]); } diff --git a/ui/src/components/workflow/designer/forms/_shared.tsx b/ui/src/components/workflow/designer/forms/_shared.tsx index 069865ee..f4ff42be 100644 --- a/ui/src/components/workflow/designer/forms/_shared.tsx +++ b/ui/src/components/workflow/designer/forms/_shared.tsx @@ -7,7 +7,7 @@ import { Anchor, type AnchorProps, App, Button, Drawer, Dropdown, Flex, type For import { isEqual } from "radash"; import Show from "@/components/Show"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; import { type NodeRegistry } from "../nodes/typings"; @@ -60,7 +60,7 @@ export const NodeConfigDrawer = ({ children, afterClose, anchor, footer = true, node.form!.setValueIn("config", formValues); node.form!.validate(); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; } finally { diff --git a/ui/src/pages/accesses/AccessList.tsx b/ui/src/pages/accesses/AccessList.tsx index 21b10812..c4e1bfa7 100644 --- a/ui/src/pages/accesses/AccessList.tsx +++ b/ui/src/pages/accesses/AccessList.tsx @@ -17,7 +17,7 @@ import { ACCESS_USAGES, accessProvidersMap } from "@/domain/provider"; import { useAppSettings, useZustandShallowSelector } from "@/hooks"; import { get as getAccess } from "@/repository/access"; import { useAccessesStore } from "@/stores/access"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; type AccessUsages = AccessEditDrawerProps["usage"]; @@ -41,7 +41,7 @@ const AccessList = () => { } console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); }); }); @@ -327,7 +327,7 @@ const AccessList = () => { refreshData(); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -359,7 +359,7 @@ const AccessList = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -429,7 +429,7 @@ const AccessList = () => { } extra={ loadError ? ( diff --git a/ui/src/pages/accesses/AccessNew.tsx b/ui/src/pages/accesses/AccessNew.tsx index 0543af18..dc0ce09d 100644 --- a/ui/src/pages/accesses/AccessNew.tsx +++ b/ui/src/pages/accesses/AccessNew.tsx @@ -10,7 +10,7 @@ import { type AccessModel } from "@/domain/access"; import { ACCESS_USAGES } from "@/domain/provider"; import { useZustandShallowSelector } from "@/hooks"; import { useAccessesStore } from "@/stores/access"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const AccessNew = () => { const navigate = useNavigate(); @@ -51,7 +51,7 @@ const AccessNew = () => { navigate(`/accesses?usage=${providerUsage}`, { replace: true }); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; } finally { diff --git a/ui/src/pages/certificates/CertificateList.tsx b/ui/src/pages/certificates/CertificateList.tsx index fa58853a..8dee4887 100644 --- a/ui/src/pages/certificates/CertificateList.tsx +++ b/ui/src/pages/certificates/CertificateList.tsx @@ -15,7 +15,7 @@ import { CERTIFICATE_SOURCES, type CertificateModel } from "@/domain/certificate import { useAppSettings, useZustandShallowSelector } from "@/hooks"; import { get as getCertificate, list as listCertificates, remove as removeCertificate } from "@/repository/certificate"; import { usePersistenceSettingsStore } from "@/stores/settings"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const CertificateList = () => { const navigate = useNavigate(); @@ -290,7 +290,7 @@ const CertificateList = () => { } console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; }, @@ -343,7 +343,7 @@ const CertificateList = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -371,7 +371,7 @@ const CertificateList = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -403,7 +403,7 @@ const CertificateList = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -463,7 +463,7 @@ const CertificateList = () => { } extra={ loadError ? ( diff --git a/ui/src/pages/dashboard/Dashboard.tsx b/ui/src/pages/dashboard/Dashboard.tsx index 405e5ecf..b847c314 100644 --- a/ui/src/pages/dashboard/Dashboard.tsx +++ b/ui/src/pages/dashboard/Dashboard.tsx @@ -30,7 +30,7 @@ import { type WorkflowRunModel } from "@/domain/workflowRun"; import { useBrowserTheme, useVersionChecker } from "@/hooks"; import { get as getWorkflowRun, list as listWorkflowRuns } from "@/repository/workflowRun"; import { mergeCls } from "@/utils/css"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const Dashboard = () => { const { t } = useTranslation(); @@ -149,7 +149,7 @@ const StatisticCards = ({ className, style }: { className?: string; style?: Reac } console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; }, @@ -365,7 +365,7 @@ const WorkflowRunHistoryTable = ({ className, style }: { className?: string; sty } console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; }, @@ -400,7 +400,7 @@ const WorkflowRunHistoryTable = ({ className, style }: { className?: string; sty } extra={ loadError ? ( diff --git a/ui/src/pages/login/Login.tsx b/ui/src/pages/login/Login.tsx index 9cc9768b..45cf9efd 100644 --- a/ui/src/pages/login/Login.tsx +++ b/ui/src/pages/login/Login.tsx @@ -13,7 +13,7 @@ import AppVersion from "@/components/AppVersion"; import { useAntdForm, useBrowserTheme } from "@/hooks"; import { authWithPassword } from "@/repository/admin"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const Login = () => { const navigage = useNavigate(); @@ -59,7 +59,7 @@ const Login = () => { await authWithPassword(values.username, values.password); await navigage("/"); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; } diff --git a/ui/src/pages/presets/PresetListNotifyTemplates.tsx b/ui/src/pages/presets/PresetListNotifyTemplates.tsx index 6f0cbdc8..19b8d5f3 100644 --- a/ui/src/pages/presets/PresetListNotifyTemplates.tsx +++ b/ui/src/pages/presets/PresetListNotifyTemplates.tsx @@ -12,7 +12,7 @@ import DrawerForm from "@/components/DrawerForm"; import Tips from "@/components/Tips"; import { useAntdForm, useZustandShallowSelector } from "@/hooks"; import { useNotifyTemplatesStore } from "@/stores/settings"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const MAX_TEMPLATE_COUNT = 99; @@ -35,7 +35,7 @@ const PresetListNotifyTemplates = () => { } console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); }); }); @@ -77,7 +77,7 @@ const PresetListNotifyTemplates = () => { await removeTemplateByIndex(index); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -90,7 +90,7 @@ const PresetListNotifyTemplates = () => { setCreateDrawerOpen(false); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }; @@ -105,7 +105,7 @@ const PresetListNotifyTemplates = () => { setDetailDrawerOpen(false); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }; diff --git a/ui/src/pages/presets/PresetListScriptTemplates.tsx b/ui/src/pages/presets/PresetListScriptTemplates.tsx index a0adfda0..0b12029a 100644 --- a/ui/src/pages/presets/PresetListScriptTemplates.tsx +++ b/ui/src/pages/presets/PresetListScriptTemplates.tsx @@ -13,7 +13,7 @@ import DrawerForm from "@/components/DrawerForm"; import Tips from "@/components/Tips"; import { useAntdForm, useZustandShallowSelector } from "@/hooks"; import { useScriptTemplatesStore } from "@/stores/settings"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const MAX_TEMPLATE_COUNT = 99; @@ -35,7 +35,7 @@ const PresetListScriptTemplates = () => { } console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); }); }); @@ -77,7 +77,7 @@ const PresetListScriptTemplates = () => { await removeTemplateByIndex(index); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -90,7 +90,7 @@ const PresetListScriptTemplates = () => { setCreateDrawerOpen(false); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }; @@ -105,7 +105,7 @@ const PresetListScriptTemplates = () => { setDetailDrawerOpen(false); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }; diff --git a/ui/src/pages/settings/SettingsAccount.tsx b/ui/src/pages/settings/SettingsAccount.tsx index 23bd4293..48f5001c 100644 --- a/ui/src/pages/settings/SettingsAccount.tsx +++ b/ui/src/pages/settings/SettingsAccount.tsx @@ -7,7 +7,7 @@ import { z } from "zod"; import { useAntdForm } from "@/hooks"; import { authWithPassword, getAuthStore, save as saveAdmin } from "@/repository/admin"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const SettingsAccount = () => { const { t } = useTranslation(); @@ -60,7 +60,7 @@ const SettingsAccountUsername = ({ className, style }: { className?: string; sty navigate("/login"); }, 500); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; } @@ -163,7 +163,7 @@ const SettingsAccountPassword = ({ className, style }: { className?: string; sty navigate("/login"); }, 500); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; } diff --git a/ui/src/pages/settings/SettingsDiagnostics.tsx b/ui/src/pages/settings/SettingsDiagnostics.tsx index b8be956f..bbe0dd62 100644 --- a/ui/src/pages/settings/SettingsDiagnostics.tsx +++ b/ui/src/pages/settings/SettingsDiagnostics.tsx @@ -10,7 +10,7 @@ import Show from "@/components/Show"; import { listCronJobs, listLogs } from "@/repository/system"; import { getNextCronExecutions } from "@/utils/cron"; import { mergeCls } from "@/utils/css"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const SettingsDiagnostics = () => { const { t } = useTranslation(); @@ -139,7 +139,7 @@ const SettingsDiagnosticsLogs = ({ className, style }: { className?: string; sty - {loadError ? `> ${getErrMsg(loadError)}` : "> no logs avaiable"} + {loadError ? `> ${unwrapErrMsg(loadError)}` : "> no logs avaiable"} @@ -241,7 +241,7 @@ const SettingsDiagnosticsCrons = ({ className, style }: { className?: string; st loading={loading} locale={{ emptyText: ( - + {loadError && ( } type="primary" onClick={handleReloadClick}> {t("common.button.reload")} diff --git a/ui/src/pages/settings/SettingsPersistence.tsx b/ui/src/pages/settings/SettingsPersistence.tsx index 5fabb7c6..fe16a9a0 100644 --- a/ui/src/pages/settings/SettingsPersistence.tsx +++ b/ui/src/pages/settings/SettingsPersistence.tsx @@ -10,7 +10,7 @@ import Show from "@/components/Show"; import { type PersistenceSettingsContent } from "@/domain/settings"; import { useAntdForm, useZustandShallowSelector } from "@/hooks"; import { usePersistenceSettingsStore } from "@/stores/settings"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const SettingsPersistence = () => { const { t } = useTranslation(); @@ -28,7 +28,7 @@ const SettingsPersistence = () => { message.success(t("common.text.operation_succeeded")); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }; diff --git a/ui/src/pages/settings/SettingsSSLProvider.tsx b/ui/src/pages/settings/SettingsSSLProvider.tsx index 1bf03bae..6bddec41 100644 --- a/ui/src/pages/settings/SettingsSSLProvider.tsx +++ b/ui/src/pages/settings/SettingsSSLProvider.tsx @@ -13,7 +13,7 @@ import { type SSLProviderSettingsContent } from "@/domain/settings"; import { useAntdForm, useZustandShallowSelector } from "@/hooks"; import { useSSLProviderSettingsStore } from "@/stores/settings"; import { mergeCls } from "@/utils/css"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const SettingsSSLProvider = () => { const { t } = useTranslation(); @@ -86,7 +86,7 @@ const SettingsSSLProvider = () => { message.success(t("common.text.operation_succeeded")); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } finally { setFormPending(false); } diff --git a/ui/src/pages/workflows/WorkflowDetail.tsx b/ui/src/pages/workflows/WorkflowDetail.tsx index 13aa7076..7008a51b 100644 --- a/ui/src/pages/workflows/WorkflowDetail.tsx +++ b/ui/src/pages/workflows/WorkflowDetail.tsx @@ -11,7 +11,7 @@ import { WORKFLOW_RUN_STATUSES } from "@/domain/workflowRun"; import { useZustandShallowSelector } from "@/hooks"; import { useWorkflowStore } from "@/stores/workflow"; import { mergeCls } from "@/utils/css"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const WorkflowDetail = () => { const location = useLocation(); @@ -26,7 +26,7 @@ const WorkflowDetail = () => { useEffect(() => { Promise.try(() => workflowState.init(workflowId!)).catch((err) => { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); }); return () => { @@ -102,7 +102,7 @@ const WorkflowDetail = () => { await workflowState.setEnabled(!workflow.enabled); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }; @@ -205,7 +205,7 @@ const WorkflowDetailBaseName = () => { try { await workflowStore.setName(value); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; } @@ -283,7 +283,7 @@ const WorkflowDetailBaseDescription = () => { try { await workflowStore.setDescription(value); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; } diff --git a/ui/src/pages/workflows/WorkflowDetailDesign.tsx b/ui/src/pages/workflows/WorkflowDetailDesign.tsx index ea474ed5..3d097fce 100644 --- a/ui/src/pages/workflows/WorkflowDetailDesign.tsx +++ b/ui/src/pages/workflows/WorkflowDetailDesign.tsx @@ -12,7 +12,7 @@ import WorkflowGraphExportModal from "@/components/workflow/WorkflowGraphExportM import WorkflowGraphImportModal from "@/components/workflow/WorkflowGraphImportModal"; import { useAppSettings, useZustandShallowSelector } from "@/hooks"; import { useWorkflowStore } from "@/stores/workflow"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const WorkflowDetailDesign = () => { const { t } = useTranslation(); @@ -55,7 +55,7 @@ const WorkflowDetailDesign = () => { await workflowStore.orchestrate(graph); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } finally { designerPending.current = false; } @@ -72,7 +72,7 @@ const WorkflowDetailDesign = () => { message.success(t("common.text.operation_succeeded")); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -94,7 +94,7 @@ const WorkflowDetailDesign = () => { message.success(t("common.text.operation_succeeded")); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -116,7 +116,7 @@ const WorkflowDetailDesign = () => { } catch (err) { console.error(err); message.destroy(loadingKey); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }); }; @@ -214,7 +214,7 @@ const WorkflowDetailDesign = () => { {!!designerError && ( - + )} diff --git a/ui/src/pages/workflows/WorkflowDetailRuns.tsx b/ui/src/pages/workflows/WorkflowDetailRuns.tsx index bc507c9c..da98776b 100644 --- a/ui/src/pages/workflows/WorkflowDetailRuns.tsx +++ b/ui/src/pages/workflows/WorkflowDetailRuns.tsx @@ -17,7 +17,7 @@ import { WORKFLOW_RUN_STATUSES, type WorkflowRunModel } from "@/domain/workflowR import { useAppSettings, useZustandShallowSelector } from "@/hooks"; import { get as getWorkflowRun, list as listWorkflowRuns, remove as removeWorkflowRun, subscribe as subscribeWorkflowRun } from "@/repository/workflowRun"; import { useWorkflowStore } from "@/stores/workflow"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const WorkflowDetailRuns = () => { const { t } = useTranslation(); @@ -211,7 +211,7 @@ const WorkflowDetailRuns = () => { } console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; }, @@ -274,7 +274,7 @@ const WorkflowDetailRuns = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -300,7 +300,7 @@ const WorkflowDetailRuns = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -334,7 +334,7 @@ const WorkflowDetailRuns = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -358,7 +358,7 @@ const WorkflowDetailRuns = () => { } /> ), diff --git a/ui/src/pages/workflows/WorkflowList.tsx b/ui/src/pages/workflows/WorkflowList.tsx index 21c10a1d..e89d5147 100644 --- a/ui/src/pages/workflows/WorkflowList.tsx +++ b/ui/src/pages/workflows/WorkflowList.tsx @@ -14,7 +14,7 @@ import WorkflowStatus from "@/components/workflow/WorkflowStatus"; import { WORKFLOW_TRIGGERS, type WorkflowModel, duplicateNodes } from "@/domain/workflow"; import { useAppSettings } from "@/hooks"; import { get as getWorkflow, list as listWorkflows, remove as removeWorkflow, save as saveWorkflow } from "@/repository/workflow"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const WorkflowList = () => { const navigate = useNavigate(); @@ -280,7 +280,7 @@ const WorkflowList = () => { } console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; }, @@ -335,7 +335,7 @@ const WorkflowList = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }; @@ -346,7 +346,7 @@ const WorkflowList = () => { message.info(t("workflow.action.execute.prompt")); } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }; @@ -371,7 +371,7 @@ const WorkflowList = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -397,7 +397,7 @@ const WorkflowList = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -429,7 +429,7 @@ const WorkflowList = () => { } } catch (err) { console.error(err); - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); } }, }); @@ -493,7 +493,7 @@ const WorkflowList = () => { } extra={ loadError ? ( diff --git a/ui/src/pages/workflows/WorkflowNew.tsx b/ui/src/pages/workflows/WorkflowNew.tsx index ea7da045..adc9ad76 100644 --- a/ui/src/pages/workflows/WorkflowNew.tsx +++ b/ui/src/pages/workflows/WorkflowNew.tsx @@ -15,7 +15,7 @@ import { newNode, } from "@/domain/workflow"; import { save as saveWorkflow } from "@/repository/workflow"; -import { getErrMsg } from "@/utils/error"; +import { unwrapErrMsg } from "@/utils/error"; const TEMPLATE_KEY_BLANK = "blank" as const; const TEMPLATE_KEY_STANDARD = "standard" as const; @@ -242,7 +242,7 @@ const WorkflowNew = () => { workflow = await saveWorkflow(workflow); navigate(`/workflows/${workflow.id}`, { replace: true }); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; } finally { @@ -266,7 +266,7 @@ const WorkflowNew = () => { workflow = await saveWorkflow(workflow); navigate(`/workflows/${workflow.id}`, { replace: true }); } catch (err) { - notification.error({ title: t("common.text.request_error"), description: getErrMsg(err) }); + notification.error({ title: t("common.text.request_error"), description: unwrapErrMsg(err) }); throw err; } finally { diff --git a/ui/src/utils/error.ts b/ui/src/utils/error.ts index 063eb5dc..141e8d20 100644 --- a/ui/src/utils/error.ts +++ b/ui/src/utils/error.ts @@ -1,15 +1,15 @@ import { ClientResponseError } from "pocketbase"; -export const getErrMsg = (error: unknown): string => { +export const unwrapErrMsg = (error: unknown): string => { if (error instanceof ClientResponseError) { - return Object.keys(error.response ?? {}).length ? getErrMsg(error.response) : error.message; + return Object.keys(error.response ?? {}).length ? unwrapErrMsg(error.response) : error.message; } else if (error instanceof Error) { return error.message; } else if (typeof error === "object" && error != null) { if ("message" in error) { - return getErrMsg(error.message); + return unwrapErrMsg(error.message); } else if ("msg" in error) { - return getErrMsg(error.msg); + return unwrapErrMsg(error.msg); } } else if (typeof error === "string") { return error || "Unknown error";