Move some exception logic into ExceptionUtil
This commit is contained in:
@@ -24,6 +24,7 @@ import com.seibel.distanthorizons.api.interfaces.override.worldGenerator.IDhApiW
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverrideInjector;
|
||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
||||
@@ -125,7 +126,10 @@ public class BatchGenerator implements IDhApiWorldGenerator
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (!LodUtil.isInterruptOrReject(e)) LOGGER.error("Error starting future for chunk generation", e);
|
||||
if (!ExceptionUtil.isInterruptOrReject(e))
|
||||
{
|
||||
LOGGER.error("Error starting future for chunk generation", e);
|
||||
}
|
||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||
future.completeExceptionally(e);
|
||||
return future;
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dataObjects.transformers.LodDataBuilder;
|
||||
import com.seibel.distanthorizons.core.render.renderer.DebugRenderer;
|
||||
import com.seibel.distanthorizons.core.render.renderer.IDebugRenderable;
|
||||
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil.AssertFailureException;
|
||||
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
||||
import com.seibel.distanthorizons.core.util.objects.DataCorruptedException;
|
||||
@@ -358,7 +359,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
||||
if (exception != null)
|
||||
{
|
||||
// don't log the shutdown exceptions
|
||||
if (!LodUtil.isInterruptOrReject(exception))
|
||||
if (!ExceptionUtil.isInterruptOrReject(exception))
|
||||
{
|
||||
LOGGER.error("Error generating data for pos: " + DhSectionPos.toString(taskPos), exception);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Handles both single-player/server-side world gen and client side LOD requests.
|
||||
* TODO rename
|
||||
*/
|
||||
public class LodRequestModule implements Closeable
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.seibel.distanthorizons.core.util;
|
||||
import com.seibel.distanthorizons.core.util.objects.UncheckedInterruptedException;
|
||||
|
||||
import java.nio.channels.ClosedByInterruptException;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
@@ -28,4 +29,16 @@ public class ExceptionUtil
|
||||
}
|
||||
|
||||
|
||||
public static boolean isInterruptOrReject(Throwable t)
|
||||
{
|
||||
Throwable unwrapped = ensureUnwrap(t);
|
||||
return UncheckedInterruptedException.isInterrupt(unwrapped) ||
|
||||
unwrapped instanceof RejectedExecutionException ||
|
||||
unwrapped instanceof CancellationException;
|
||||
}
|
||||
public static Throwable ensureUnwrap(Throwable t)
|
||||
{
|
||||
return t instanceof CompletionException ? ensureUnwrap(t.getCause()) : t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,21 +21,11 @@ package com.seibel.distanthorizons.core.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiVanillaOverdraw;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.render.vertexFormat.DefaultLodVertexFormats;
|
||||
import com.seibel.distanthorizons.core.render.vertexFormat.LodVertexFormat;
|
||||
import com.seibel.distanthorizons.core.util.objects.UncheckedInterruptedException;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
|
||||
/**
|
||||
@@ -191,17 +181,6 @@ public class LodUtil
|
||||
throw new AssertFailureException("Assert Not Reach failed:\n " + message);
|
||||
}
|
||||
|
||||
public static Throwable ensureUnwrap(Throwable t)
|
||||
{
|
||||
return t instanceof CompletionException ? ensureUnwrap(t.getCause()) : t;
|
||||
}
|
||||
|
||||
public static boolean isInterruptOrReject(Throwable t)
|
||||
{
|
||||
Throwable unwrapped = LodUtil.ensureUnwrap(t);
|
||||
return UncheckedInterruptedException.isInterrupt(unwrapped) ||
|
||||
unwrapped instanceof RejectedExecutionException ||
|
||||
unwrapped instanceof CancellationException;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.util.objects;
|
||||
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
||||
|
||||
import java.util.concurrent.CompletionException;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class UncheckedInterruptedException extends RuntimeException
|
||||
}
|
||||
public static boolean isInterrupt(Throwable t)
|
||||
{
|
||||
Throwable unwrapped = LodUtil.ensureUnwrap(t);
|
||||
Throwable unwrapped = ExceptionUtil.ensureUnwrap(t);
|
||||
return unwrapped instanceof InterruptedException || unwrapped instanceof UncheckedInterruptedException;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user