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); } } }