From a346e0d3676c2ed8c1580125a98e226f75f88ea7 Mon Sep 17 00:00:00 2001 From: baurine <2008.hbl@gmail.com> Date: Wed, 11 Nov 2020 15:52:16 +0800 Subject: [PATCH 1/6] ui: fix errors doesn't show bug --- ui/lib/client/index.tsx | 4 +++- ui/lib/components/ErrorBar/index.tsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/lib/client/index.tsx b/ui/lib/client/index.tsx index 907a053efd..323412cf0a 100644 --- a/ui/lib/client/index.tsx +++ b/ui/lib/client/index.tsx @@ -59,7 +59,9 @@ function initAxios() { } } const content = i18next.t(errCode) - err.message = content + // err.message = content // sometimes we can't change err.message at all, still don't know the exact reason + err.msg = content + // console.log('err', { ...err }) // you can't see message but msg field in the log if (errCode === 'error.api.unauthorized') { // Handle unauthorized error in a unified way diff --git a/ui/lib/components/ErrorBar/index.tsx b/ui/lib/components/ErrorBar/index.tsx index 8ff81e1b2e..2f797aeac7 100644 --- a/ui/lib/components/ErrorBar/index.tsx +++ b/ui/lib/components/ErrorBar/index.tsx @@ -10,7 +10,7 @@ export default function ErrorBar({ errors }: IErrorBarProps) { // show at most 3 kinds of errors const errorMsgs = useMemo( () => - _.uniq(_.map(errors, (err) => err?.message || '')) + _.uniq(_.map(errors, (err) => err?.msg || err?.message || '')) .filter((msg) => msg !== '') .slice(0, 3), [errors] From 684db553b43c27b953ee4cf3b011f720738f70de Mon Sep 17 00:00:00 2001 From: baurine <2008.hbl@gmail.com> Date: Wed, 11 Nov 2020 16:33:36 +0800 Subject: [PATCH 2/6] fix CI --- ui/dashboardApp/layout/signin/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/dashboardApp/layout/signin/index.tsx b/ui/dashboardApp/layout/signin/index.tsx index 9e291de79d..b0c9597911 100644 --- a/ui/dashboardApp/layout/signin/index.tsx +++ b/ui/dashboardApp/layout/signin/index.tsx @@ -157,7 +157,7 @@ function useSignInSubmit( singleSpa.navigateToUrl(successRoute) } catch (e) { if (!e.handled) { - setError(t('signin.message.error', { msg: e.message })) + setError(t('signin.message.error', { msg: e.msg })) onFailure() } } finally { From 51b0088f986dd539f98d08d474d889a400d0dfc2 Mon Sep 17 00:00:00 2001 From: baurine <2008.hbl@gmail.com> Date: Thu, 12 Nov 2020 15:11:39 +0800 Subject: [PATCH 3/6] Revert "fix CI" This reverts commit 684db553b43c27b953ee4cf3b011f720738f70de. --- ui/dashboardApp/layout/signin/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/dashboardApp/layout/signin/index.tsx b/ui/dashboardApp/layout/signin/index.tsx index b0c9597911..9e291de79d 100644 --- a/ui/dashboardApp/layout/signin/index.tsx +++ b/ui/dashboardApp/layout/signin/index.tsx @@ -157,7 +157,7 @@ function useSignInSubmit( singleSpa.navigateToUrl(successRoute) } catch (e) { if (!e.handled) { - setError(t('signin.message.error', { msg: e.msg })) + setError(t('signin.message.error', { msg: e.message })) onFailure() } } finally { From 5c2eda21d2b9c549d3aad6d39480bf4203a21249 Mon Sep 17 00:00:00 2001 From: baurine <2008.hbl@gmail.com> Date: Thu, 12 Nov 2020 15:12:00 +0800 Subject: [PATCH 4/6] Revert "ui: fix errors doesn't show bug" This reverts commit a346e0d3676c2ed8c1580125a98e226f75f88ea7. --- ui/lib/client/index.tsx | 4 +--- ui/lib/components/ErrorBar/index.tsx | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/lib/client/index.tsx b/ui/lib/client/index.tsx index 323412cf0a..907a053efd 100644 --- a/ui/lib/client/index.tsx +++ b/ui/lib/client/index.tsx @@ -59,9 +59,7 @@ function initAxios() { } } const content = i18next.t(errCode) - // err.message = content // sometimes we can't change err.message at all, still don't know the exact reason - err.msg = content - // console.log('err', { ...err }) // you can't see message but msg field in the log + err.message = content if (errCode === 'error.api.unauthorized') { // Handle unauthorized error in a unified way diff --git a/ui/lib/components/ErrorBar/index.tsx b/ui/lib/components/ErrorBar/index.tsx index 2f797aeac7..8ff81e1b2e 100644 --- a/ui/lib/components/ErrorBar/index.tsx +++ b/ui/lib/components/ErrorBar/index.tsx @@ -10,7 +10,7 @@ export default function ErrorBar({ errors }: IErrorBarProps) { // show at most 3 kinds of errors const errorMsgs = useMemo( () => - _.uniq(_.map(errors, (err) => err?.msg || err?.message || '')) + _.uniq(_.map(errors, (err) => err?.message || '')) .filter((msg) => msg !== '') .slice(0, 3), [errors] From 31f743e1cfd4f84cb8430a342173907867ef8a7a Mon Sep 17 00:00:00 2001 From: baurine <2008.hbl@gmail.com> Date: Thu, 12 Nov 2020 15:15:56 +0800 Subject: [PATCH 5/6] ui: fix save error reason: use spread syntax for Error object will miss the message property, because it is a non-enumerable property --- .../SlowQuery/utils/useSlowQueryTableController.ts | 4 ++-- .../Statement/utils/useStatementTableController.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts b/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts index dcb4370bc7..d428d81262 100644 --- a/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts +++ b/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts @@ -117,7 +117,7 @@ export default function useSlowQueryTableController( }) setAllSchemas(res?.data || []) } catch (e) { - setErrors((prev) => [...prev, { ...e }]) + setErrors((prev) => [...prev, e]) } } querySchemas() @@ -157,7 +157,7 @@ export default function useSlowQueryTableController( setSlowQueries(res.data || []) setErrors([]) } catch (e) { - setErrors((prev) => [...prev, { ...e }]) + setErrors((prev) => [...prev, e]) } setLoadingSlowQueries(false) } diff --git a/ui/lib/apps/Statement/utils/useStatementTableController.ts b/ui/lib/apps/Statement/utils/useStatementTableController.ts index 5abcf2499b..2c66f32a3b 100644 --- a/ui/lib/apps/Statement/utils/useStatementTableController.ts +++ b/ui/lib/apps/Statement/utils/useStatementTableController.ts @@ -134,7 +134,7 @@ export default function useStatementTableController( }) setEnable(res?.data.enable!) } catch (e) { - setErrors((prev) => [...prev, { ...e }]) + setErrors((prev) => [...prev, e]) } } @@ -145,7 +145,7 @@ export default function useStatementTableController( }) setAllSchemas(res?.data || []) } catch (e) { - setErrors((prev) => [...prev, { ...e }]) + setErrors((prev) => [...prev, e]) } } @@ -156,7 +156,7 @@ export default function useStatementTableController( }) setAllTimeRanges(res?.data || []) } catch (e) { - setErrors((prev) => [...prev, { ...e }]) + setErrors((prev) => [...prev, e]) } } @@ -167,7 +167,7 @@ export default function useStatementTableController( }) setAllStmtTypes(res?.data || []) } catch (e) { - setErrors((prev) => [...prev, { ...e }]) + setErrors((prev) => [...prev, e]) } } @@ -213,7 +213,7 @@ export default function useStatementTableController( setStatements(res?.data || []) setErrors([]) } catch (e) { - setErrors((prev) => [...prev, { ...e }]) + setErrors((prev) => [...prev, e]) } setLoadingStatements(false) } From f87b54a636692a8652572780df4560dfe5da4e50 Mon Sep 17 00:00:00 2001 From: baurine <2008.hbl@gmail.com> Date: Thu, 12 Nov 2020 15:30:53 +0800 Subject: [PATCH 6/6] refine --- .../SlowQuery/utils/useSlowQueryTableController.ts | 4 ++-- .../Statement/utils/useStatementTableController.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts b/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts index d428d81262..a2348d98ce 100644 --- a/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts +++ b/ui/lib/apps/SlowQuery/utils/useSlowQueryTableController.ts @@ -117,7 +117,7 @@ export default function useSlowQueryTableController( }) setAllSchemas(res?.data || []) } catch (e) { - setErrors((prev) => [...prev, e]) + setErrors((prev) => prev.concat(e)) } } querySchemas() @@ -157,7 +157,7 @@ export default function useSlowQueryTableController( setSlowQueries(res.data || []) setErrors([]) } catch (e) { - setErrors((prev) => [...prev, e]) + setErrors((prev) => prev.concat(e)) } setLoadingSlowQueries(false) } diff --git a/ui/lib/apps/Statement/utils/useStatementTableController.ts b/ui/lib/apps/Statement/utils/useStatementTableController.ts index 2c66f32a3b..bf713252a0 100644 --- a/ui/lib/apps/Statement/utils/useStatementTableController.ts +++ b/ui/lib/apps/Statement/utils/useStatementTableController.ts @@ -134,7 +134,7 @@ export default function useStatementTableController( }) setEnable(res?.data.enable!) } catch (e) { - setErrors((prev) => [...prev, e]) + setErrors((prev) => prev.concat(e)) } } @@ -145,7 +145,7 @@ export default function useStatementTableController( }) setAllSchemas(res?.data || []) } catch (e) { - setErrors((prev) => [...prev, e]) + setErrors((prev) => prev.concat(e)) } } @@ -156,7 +156,7 @@ export default function useStatementTableController( }) setAllTimeRanges(res?.data || []) } catch (e) { - setErrors((prev) => [...prev, e]) + setErrors((prev) => prev.concat(e)) } } @@ -167,7 +167,7 @@ export default function useStatementTableController( }) setAllStmtTypes(res?.data || []) } catch (e) { - setErrors((prev) => [...prev, e]) + setErrors((prev) => prev.concat(e)) } } @@ -213,7 +213,7 @@ export default function useStatementTableController( setStatements(res?.data || []) setErrors([]) } catch (e) { - setErrors((prev) => [...prev, e]) + setErrors((prev) => prev.concat(e)) } setLoadingStatements(false) }