Przeglądaj źródła

handle error of SearchPage

Yuki Takei 6 lat temu
rodzic
commit
66c50f3055

+ 3 - 3
src/client/js/components/SearchPage.jsx

@@ -7,6 +7,8 @@ import { withTranslation } from 'react-i18next';
 import { createSubscribedElement } from './UnstatedUtils';
 import AppContainer from '../services/AppContainer';
 
+import { toastError } from '../util/apiNotification';
+
 import SearchPageForm from './SearchPage/SearchPageForm';
 import SearchResult from './SearchPage/SearchResult';
 
@@ -83,9 +85,7 @@ class SearchPage extends React.Component {
         });
       })
       .catch((err) => {
-        // TODO error
-        // this.setState({
-        // });
+        toastError(err);
       });
   }
 

+ 1 - 5
src/server/routes/search.js

@@ -35,10 +35,6 @@ module.exports = function(crowi, app) {
 
   actions.searchPage = function(req, res) {
     const keyword = req.query.q || null;
-    const { searchService } = crowi;
-    if (!searchService.isReachable) {
-      return res.json(ApiResponse.error('Configuration of ELASTICSEARCH_URI is required.'));
-    }
 
     return res.render('search', {
       q: keyword,
@@ -127,7 +123,7 @@ module.exports = function(crowi, app) {
 
     const { searchService } = crowi;
     if (!searchService.isReachable) {
-      return res.json(ApiResponse.error('Configuration of ELASTICSEARCH_URI is required.'));
+      return res.json(ApiResponse.error('SearchService is not reachable.'));
     }
 
     let userGroups = [];