Do not run GameVersion.minecraftVersion on UI thread

This commit is contained in:
yushijinhun
2019-02-24 12:25:19 +08:00
parent 7fcd4d94a6
commit 9f85e4a63b
2 changed files with 32 additions and 8 deletions

View File

@@ -25,6 +25,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Function;
/**
*
@@ -199,6 +200,16 @@ public final class Lang {
return t;
}
/**
* This is a useful function to prevent exceptions being eaten when using CompletableFuture.
* You can write:
* ... .exceptionally(handleUncaught);
*/
public static final Function<Throwable, Void> handleUncaught = e -> {
handleUncaughtException(e);
return null;
};
public static void handleUncaughtException(Throwable e) {
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
}