File tree Expand file tree Collapse file tree
main/java/cz/o2/proxima/core/util
test/java/cz/o2/proxima/core/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919import cz .o2 .proxima .core .functional .Consumer ;
2020import cz .o2 .proxima .core .functional .UnaryFunction ;
2121import java .io .Serializable ;
22+ import lombok .extern .slf4j .Slf4j ;
2223
2324/** Utilities related to exception throwing and handling. */
25+ @ Slf4j
2426public class ExceptionUtils {
2527
2628 /**
@@ -184,5 +186,14 @@ public static void rethrowAsIllegalStateException(Throwable cause) {
184186 throw new IllegalStateException (cause );
185187 }
186188
189+ /** Swallow any Exception. */
190+ public static void ignoring (ThrowingRunnable runnable ) {
191+ try {
192+ runnable .run ();
193+ } catch (Exception ex ) {
194+ log .warn ("Caught error, ignoring as instructed." , ex );
195+ }
196+ }
197+
187198 private ExceptionUtils () {}
188199}
Original file line number Diff line number Diff line change @@ -69,4 +69,13 @@ public void testRethrowIllegalStateException() {
6969 assertEquals ("ex" , ex .getCause ().getMessage ());
7070 }
7171 }
72+
73+ @ Test
74+ public void testIgnoring () {
75+ ExceptionUtils .ignoring (
76+ () -> {
77+ throw new IllegalStateException ("ex" );
78+ });
79+ assertTrue (true );
80+ }
7281}
You can’t perform that action at this time.
0 commit comments