ソースを参照

add validateCrowi()

zamis 5 年 前
コミット
f6e0eab70b
1 ファイル変更7 行追加0 行削除
  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;