From f1caaa59ba0b178a74f2bcce1c050f5b1617eb03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.chilliet@fusiondirectory.org>
Date: Thu, 30 Jul 2020 09:12:57 +0200
Subject: [PATCH] :ambulance: fix(errors) Show previous error in trace

This helps knowing exactly where the first error happenened.

issue #6071
---
 include/errors/class_FatalError.inc           | 4 ----
 include/errors/class_FusionDirectoryError.inc | 4 ++++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/errors/class_FatalError.inc b/include/errors/class_FatalError.inc
index 4f2b8547d..ae4841c20 100644
--- a/include/errors/class_FatalError.inc
+++ b/include/errors/class_FatalError.inc
@@ -84,10 +84,6 @@ class FatalError extends Error
       $config->get_cfg_value('displayerrors') == 'TRUE') {
       $trace    = FusionDirectoryError::formatTrace($this);
       $display  .= print_a($trace, TRUE);
-      $previous = $this;
-      while ($previous = $previous->getPrevious()) {
-        $display .= print_a(FusionDirectoryError::formatTrace($previous), TRUE);
-      }
     }
 
     $display .= '</body></html>';
diff --git a/include/errors/class_FusionDirectoryError.inc b/include/errors/class_FusionDirectoryError.inc
index ce1c925cc..661e67b1d 100644
--- a/include/errors/class_FusionDirectoryError.inc
+++ b/include/errors/class_FusionDirectoryError.inc
@@ -76,6 +76,10 @@ class FusionDirectoryError extends Error
       ]
     );
 
+    if ($previous = $throwable->getPrevious()) {
+      $trace[] = static::formatTrace($previous);
+    }
+
     return $trace;
   }
 }
-- 
GitLab