diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml
index 4f06c788fd42..d8c83fb7ba08 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 f18e4d4a960f..11af3f39981c 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 faf9fb92e5ca..4edf02679eb4 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 HeapElement getElement() throws EmptyHeapException {
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 288a1932ddad..f220fe492399 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 HeapElement getElement() throws EmptyHeapException {
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);
}
}
}