From bebf1544b4d84c5cb86b655dbf9e8fc1e4cd6104 Mon Sep 17 00:00:00 2001
From: Sebastian Mihalache <sebastian.mihalache@gmail.con>
Date: Thu, 9 Aug 2018 14:42:56 +0300
Subject: [PATCH] fix(user-helper): throw error if no EiC is found

---
 packages/component-helper-service/src/services/User.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/packages/component-helper-service/src/services/User.js b/packages/component-helper-service/src/services/User.js
index 2eb092cee..39d038968 100644
--- a/packages/component-helper-service/src/services/User.js
+++ b/packages/component-helper-service/src/services/User.js
@@ -45,7 +45,12 @@ class User {
     const { UserModel } = this
     const users = await UserModel.all()
 
-    return users.filter(user => user.editorInChief)
+    const eics = users.filter(user => user.editorInChief)
+    if (eics.length === 0) {
+      throw new Error('No Editor in Chief has been found')
+    }
+
+    return eics
   }
 
   async updateUserTeams({ userId, teamId }) {
-- 
GitLab