Ver Fonte

add validateCrowi()

zamis há 5 anos atrás
pai
commit
f6e0eab70b
1 ficheiros alterados com 7 adições e 0 exclusões
  1. 7 0
      src/server/service/page.js

+ 7 - 0
src/server/service/page.js

@@ -106,6 +106,7 @@ class PageService {
       pageEvent.on('update', pageEvent.onUpdate);
     }
 
+    this.validateCrowi();
     const { _id, path } = pageData;
     const socketClientId = options.socketClientId || null;
 
@@ -134,6 +135,12 @@ class PageService {
     }));
   }
 
+  validateCrowi() {
+    if (this.crowi == null) {
+      throw new Error('"crowi" is null. Init User model with "crowi" argument first.');
+    }
+  }
+
 }
 
 module.exports = PageService;