From f3890974390b272cb94a2b05ee2fa95aa9c39d8d Mon Sep 17 00:00:00 2001 From: goodmice Date: Tue, 7 Dec 2021 19:37:13 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D1=83=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B4=D0=BB=D1=8F=20invokeWebApiWrapperAsync=20?= =?UTF-8?q?=D0=B2=20=D0=BA=D0=B0=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=B5=20?= =?UTF-8?q?=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4,=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=D0=BD=D0=B8=D0=BC=D0=B0=D1=8E=D1=89=D0=B8=D0=B9=20=D1=81?= =?UTF-8?q?=D0=B0=D0=BC=D1=83=D1=8E=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83?= =?UTF-8?q?=20=D0=B8=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89=D0=B0?= =?UTF-8?q?=D1=8E=D1=89=D0=B8=D0=B9=20=D1=82=D0=B5=D0=BA=D1=81=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/factory.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/factory.ts b/src/components/factory.ts index 6402027..ab16629 100644 --- a/src/components/factory.ts +++ b/src/components/factory.ts @@ -31,7 +31,11 @@ export const notify = (body: string|any, notifyType:string ='info', other?: any) type asyncFunction = (...args:any) => Promise; -export const invokeWebApiWrapperAsync = async (funcAsync: asyncFunction, setShowLoader: Dispatch>, errorNotifyText: string) => { +export const invokeWebApiWrapperAsync = async ( + funcAsync: asyncFunction, + setShowLoader: Dispatch>, + errorNotifyText: (string | ((ex: unknown) => string)) +) => { if(setShowLoader) setShowLoader(true) try{ @@ -39,8 +43,11 @@ export const invokeWebApiWrapperAsync = async (funcAsync: asyncFunction, setShow } catch (ex) { if(process.env.NODE_ENV === 'development') console.error(ex) - if(errorNotifyText) - notify(errorNotifyText, 'error') + if(errorNotifyText) { + if (typeof errorNotifyText === 'function') + notify(errorNotifyText(ex), 'error') + else notify(errorNotifyText, 'error') + } } finally{ if(setShowLoader) setShowLoader(false)