From 7bff82f175912b76bc514597d08d85c32aca1a8c Mon Sep 17 00:00:00 2001
From: Piotr Idzik <65706193+vil02@users.noreply.github.com>
Date: Thu, 9 May 2024 17:15:36 +0200
Subject: [PATCH] style: include `LEST_LOST_EXCEPTION_STACK_TRACE` (#5150)
---
spotbugs-exclude.xml | 3 ---
.../datastructures/heaps/EmptyHeapException.java | 4 ++++
.../java/com/thealgorithms/datastructures/heaps/MaxHeap.java | 2 +-
.../java/com/thealgorithms/datastructures/heaps/MinHeap.java | 2 +-
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml
index 4f06c788..d8c83fb7 100644
--- a/spotbugs-exclude.xml
+++ b/spotbugs-exclude.xml
@@ -252,9 +252,6 @@
-
-
-
diff --git a/src/main/java/com/thealgorithms/datastructures/heaps/EmptyHeapException.java b/src/main/java/com/thealgorithms/datastructures/heaps/EmptyHeapException.java
index f18e4d4a..11af3f39 100644
--- a/src/main/java/com/thealgorithms/datastructures/heaps/EmptyHeapException.java
+++ b/src/main/java/com/thealgorithms/datastructures/heaps/EmptyHeapException.java
@@ -10,4 +10,8 @@ public class EmptyHeapException extends Exception {
public EmptyHeapException(String message) {
super(message);
}
+
+ public EmptyHeapException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/src/main/java/com/thealgorithms/datastructures/heaps/MaxHeap.java b/src/main/java/com/thealgorithms/datastructures/heaps/MaxHeap.java
index faf9fb92..4edf0267 100644
--- a/src/main/java/com/thealgorithms/datastructures/heaps/MaxHeap.java
+++ b/src/main/java/com/thealgorithms/datastructures/heaps/MaxHeap.java
@@ -123,7 +123,7 @@ public class MaxHeap implements Heap {
try {
return extractMax();
} catch (Exception e) {
- throw new EmptyHeapException("Heap is empty. Error retrieving element");
+ throw new EmptyHeapException("Heap is empty. Error retrieving element", e);
}
}
}
diff --git a/src/main/java/com/thealgorithms/datastructures/heaps/MinHeap.java b/src/main/java/com/thealgorithms/datastructures/heaps/MinHeap.java
index 288a1932..f220fe49 100644
--- a/src/main/java/com/thealgorithms/datastructures/heaps/MinHeap.java
+++ b/src/main/java/com/thealgorithms/datastructures/heaps/MinHeap.java
@@ -117,7 +117,7 @@ public class MinHeap implements Heap {
try {
return extractMin();
} catch (Exception e) {
- throw new EmptyHeapException("Heap is empty. Error retrieving element");
+ throw new EmptyHeapException("Heap is empty. Error retrieving element", e);
}
}
}