From 6a1a006b9e81c74a1370ce498a536ae8859469df Mon Sep 17 00:00:00 2001 From: vil02 Date: Wed, 8 May 2024 20:52:37 +0200 Subject: [PATCH] style: include `LEST_LOST_EXCEPTION_STACK_TRACE` --- 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 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); } } }