From 633ebb4ce440cce90e00325b5c33c7d14d211a72 Mon Sep 17 00:00:00 2001
From: Yoan VALLET <ext.sopra.yvallet@grandlyon.com>
Date: Wed, 24 Mar 2021 16:02:38 +0100
Subject: [PATCH] fix: error handle for deleteAll deleteAllExplorationEntities
 & deleteAllQuizEntities

---
 src/services/exploration.service.ts | 10 +++-------
 src/services/quiz.service.ts        | 10 +++-------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/services/exploration.service.ts b/src/services/exploration.service.ts
index d9f5112ea..84f916c3f 100644
--- a/src/services/exploration.service.ts
+++ b/src/services/exploration.service.ts
@@ -54,17 +54,13 @@ export default class ExplorationService {
    * @throws {Error}
    */
   public async deleteAllExplorationEntities(): Promise<boolean> {
-    try {
-      const explorations = await this.getAllExplorationEntities()
-      if (!explorations) return true
+    const explorations = await this.getAllExplorationEntities()
+    if (explorations) {
       for (let index = 0; index < explorations.length; index++) {
         await this._client.destroy(explorations[index])
       }
-      return true
-    } catch (err) {
-      console.log(err)
-      throw err
     }
+    return true
   }
 
   /**
diff --git a/src/services/quiz.service.ts b/src/services/quiz.service.ts
index 9829f19b8..db1cc9a9a 100644
--- a/src/services/quiz.service.ts
+++ b/src/services/quiz.service.ts
@@ -62,17 +62,13 @@ export default class QuizService {
    * @throws {Error}
    */
   public async deleteAllQuizEntities(): Promise<boolean> {
-    try {
-      const quizzes = await this.getAllQuizEntities()
-      if (!quizzes) return true
+    const quizzes = await this.getAllQuizEntities()
+    if (quizzes) {
       for (let index = 0; index < quizzes.length; index++) {
         await this._client.destroy(quizzes[index])
       }
-      return true
-    } catch (err) {
-      console.log(err)
-      throw err
     }
+    return true
   }
 
   /**
-- 
GitLab