| 1 | package com.renomad.minum.utils; | |
| 2 | ||
| 3 | import com.renomad.minum.logging.ILogger; | |
| 4 | ||
| 5 | /** | |
| 6 | * This exists so that we are able to slightly better manage | |
| 7 | * exceptions in a highly threaded system. Here's the thing: | |
| 8 | * exceptions stop bubbling up at the thread invocation. If we | |
| 9 | * don't take care to deal with that in some way, we can easily | |
| 10 | * just lose the information. Something could be badly broken and | |
| 11 | * we could be totally oblivious to it. This interface is to | |
| 12 | * alleviate that situation. | |
| 13 | */ | |
| 14 | @FunctionalInterface | |
| 15 | public interface ThrowingRunnable { | |
| 16 | ||
| 17 | /** | |
| 18 | * The reason this throws an exception is so that lambdas | |
| 19 | * don't need to try-catch their thrown exceptions when they | |
| 20 | * use this. | |
| 21 | */ | |
| 22 | void run() throws Exception; | |
| 23 | ||
| 24 | static Runnable throwingRunnableWrapper(ThrowingRunnable throwingRunnable, ILogger logger) { | |
| 25 |
1
1. throwingRunnableWrapper : replaced return value with null for com/renomad/minum/utils/ThrowingRunnable::throwingRunnableWrapper → KILLED |
return () -> { |
| 26 | try { | |
| 27 |
1
1. lambda$throwingRunnableWrapper$1 : removed call to com/renomad/minum/utils/ThrowingRunnable::run → KILLED |
throwingRunnable.run(); |
| 28 | } catch (Throwable ex) { | |
| 29 | logger.logAsyncError(() -> StacktraceUtils.stackTraceToString(ex)); | |
| 30 | } | |
| 31 | }; | |
| 32 | } | |
| 33 | } | |
Mutations | ||
| 25 |
1.1 |
|
| 27 |
1.1 |