WNomunomu 2 лет назад
Родитель
Сommit
3a76cc3bf7

+ 4 - 4
apps/app/src/components/Me/BasicInfoSettings.tsx

@@ -1,6 +1,5 @@
 import React from 'react';
 
-import { Logger } from 'browser-bunyan';
 import { useTranslation, i18n } from 'next-i18next';
 
 import { i18n as i18nConfig } from '^/config/next-i18next.config';
@@ -26,13 +25,14 @@ export const BasicInfoSettings = (): JSX.Element => {
       toastSuccess(t('toaster.update_successed', { target: t('Basic Info'), ns: 'commons' }));
     }
     catch (err) {
-      const code = err.message;
+      const message = err.message;
+      const code = err.code;
 
-      if (code === 'The email is already in use') {
+      if (code === 'email-is-already-in-use') {
         toastError(t('alert.email_is_already_in_use', { ns: 'commons' }));
       }
       else {
-        toastError(code);
+        toastError(message);
       }
     }
   };

+ 4 - 2
apps/app/src/stores/personal-settings.tsx

@@ -1,3 +1,4 @@
+import { ErrorV3 } from '@growi/core';
 import { useTranslation } from 'next-i18next';
 import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
 
@@ -10,6 +11,7 @@ import { apiv3Get, apiv3Put } from '../client/util/apiv3-client';
 
 import { useStaticSWR } from './use-static-swr';
 
+
 const logger = loggerFactory('growi:stores:personal-settings');
 
 
@@ -73,10 +75,10 @@ export const usePersonalSettings = (config?: SWRConfiguration): SWRResponse<IUse
       const code = err.code;
 
       if (code === 'email-is-already-in-use') {
-        throw new Error('The email is already in use');
+        throw new ErrorV3('The email is already in use', code);
       }
 
-      throw new Error('Failed to update personal data');
+      throw new ErrorV3('Failed to update personal data', 'failed-to-update-personal-data');
     }
   };