Просмотр исходного кода

to array if err is not array and change message

yusuketk 5 лет назад
Родитель
Сommit
f35cb1c5e6
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      src/client/js/components/Admin/App/AppSettingsPage.jsx

+ 7 - 5
src/client/js/components/Admin/App/AppSettingsPage.jsx

@@ -4,6 +4,7 @@ import loggerFactory from '@alias/logger';
 
 
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { toastError } from '../../../util/apiNotification';
 import { toastError } from '../../../util/apiNotification';
+import toArrayIfNot from '../../../../../lib/util/toArrayIfNot';
 
 
 import AdminAppContainer from '../../../services/AdminAppContainer';
 import AdminAppContainer from '../../../services/AdminAppContainer';
 
 
@@ -25,7 +26,7 @@ function AppSettingsPageWithContainerWithSuspense(props) {
   );
   );
 }
 }
 
 
-let retrieveError = null;
+let retrieveErrors = null;
 function AppSettingsPage(props) {
 function AppSettingsPage(props) {
   if (props.adminAppContainer.state.title === props.adminAppContainer.dummyTitle) {
   if (props.adminAppContainer.state.title === props.adminAppContainer.dummyTitle) {
     throw (async() => {
     throw (async() => {
@@ -33,18 +34,19 @@ function AppSettingsPage(props) {
         await props.adminAppContainer.retrieveAppSettingsData();
         await props.adminAppContainer.retrieveAppSettingsData();
       }
       }
       catch (err) {
       catch (err) {
-        toastError(err);
-        logger.error(err);
+        const errs = toArrayIfNot(err);
+        toastError(errs);
+        logger.error(errs);
         props.adminAppContainer.setState({
         props.adminAppContainer.setState({
           title: props.adminAppContainer.dummyTitleForError,
           title: props.adminAppContainer.dummyTitleForError,
         });
         });
-        retrieveError = err;
+        retrieveErrors = errs;
       }
       }
     })();
     })();
   }
   }
 
 
   if (props.adminAppContainer.state.title === props.adminAppContainer.dummyTitleForError) {
   if (props.adminAppContainer.state.title === props.adminAppContainer.dummyTitleForError) {
-    throw new Error(retrieveError[0].message);
+    throw new Error(`${retrieveErrors.length} errors occured`);
   }
   }
 
 
   return <AppSettingsPageContents />;
   return <AppSettingsPageContents />;