Răsfoiți Sursa

Added error handling

Taichi Masuyama 4 ani în urmă
părinte
comite
23f85307c3
1 a modificat fișierele cu 9 adăugiri și 2 ștergeri
  1. 9 2
      packages/app/src/server/routes/page.js

+ 9 - 2
packages/app/src/server/routes/page.js

@@ -336,8 +336,15 @@ module.exports = function(crowi, app) {
 
     const limit = 50;
     const offset = parseInt(req.query.offset) || 0;
-    await addRenderVarsForDescendants(renderVars, path, req.user, offset, limit, true);
-    await addRenderVarsForPageTree(renderVars, pathOrId, req.user);
+    try {
+      await addRenderVarsForDescendants(renderVars, path, req.user, offset, limit, true);
+      await addRenderVarsForPageTree(renderVars, pathOrId, req.user);
+    }
+    catch (err) {
+      // handle as not found in most cases
+      return res.render(view, renderVars);
+    }
+
     addRenderVarsWhenNotFound(renderVars, pathOrId);
 
     return res.render(view, renderVars);