Only catch Exceptions not Errors (#1186)

This commit is contained in:
glowredman authored and GitHub committed 2025-12-21 14:14:50 +01:00
1 parent 941fc88484
commit a32f9ca244
20 files changed
+45 -39

No files matched your search

@@ -55,8 +55,10 @@ public class BackhandReflectionCompat {
if (isLoaded && renderOffhandReturn != null) {
try {
renderOffhandReturn.invokeExact(partialTicks);
} catch (Throwable e) {
LOGGER.error("Failed to invoke Backhand renderOffhandReturn", e);
} catch (Error e) {
throw e;
} catch (Throwable t) {
LOGGER.error("Failed to invoke HoloInventory renderEvent", t);
isLoaded = false;
}
}
@@ -66,8 +68,10 @@ public class BackhandReflectionCompat {
if (isLoaded && getOffhandItem != null) {
try {
return (ItemStack) getOffhandItem.invokeExact(player);
} catch (Throwable e) {
LOGGER.error("Failed to invoke Backhand getOffhandItem", e);
} catch (Error e) {
throw e;
} catch (Throwable t) {
LOGGER.error("Failed to invoke HoloInventory renderEvent", t);
isLoaded = false;
}
}
@@ -75,8 +75,10 @@ public class HoloInventoryReflectionCompat {
} else {
renderEventMethod.invokeExact(event);
}
} catch (Throwable e) {
LOGGER.error("Failed to invoke HoloInventory renderEvent", e);
} catch (Error e) {
throw e;
} catch (Throwable t) {
LOGGER.error("Failed to invoke HoloInventory renderEvent", t);
isLoaded = false;
}
}
@@ -85,8 +87,10 @@ public class HoloInventoryReflectionCompat {
if (!isLoaded) return;
try {
angelicaOverrideSetter.invokeExact(value);
} catch (Throwable e) {
LOGGER.error("Failed to set HoloInventory angelicaOverride", e);
} catch (Error e) {
throw e;
} catch (Throwable t) {
LOGGER.error("Failed to invoke HoloInventory renderEvent", t);
isLoaded = false;
}
}
@@ -129,7 +129,7 @@ public class ColorizeBlock {
static {
try {
reset();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -46,7 +46,7 @@ public class ColorizeEntity {
static {
try {
reset();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -36,7 +36,7 @@ public class ColorizeItem {
static {
try {
reset();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -63,7 +63,7 @@ public class ColorizeWorld {
static {
try {
reset();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -35,7 +35,7 @@ public class Colorizer {
static {
try {
reset();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
TexturePackChangeHandler.register(new TexturePackChangeHandler(MCPatcherUtils.CUSTOM_COLORS, 2) {
@@ -77,7 +77,7 @@ class PotionReplacer {
i);
}
}
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -50,7 +50,7 @@ public class BlockFaceMatcher {
if (!matcher.isAll()) {
return matcher;
}
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -49,7 +49,7 @@ public class CTMUtils {
Class.forName(MCPatcherUtils.RENDER_PASS_CLASS)
.getMethod("finish")
.invoke(null);
} catch (Throwable ignore) {}
} catch (Exception ignore) {}
TexturePackChangeHandler.register(new TexturePackChangeHandler(MCPatcherUtils.CONNECTED_TEXTURES, 3) {
@@ -61,9 +61,7 @@ public class CTMUtils {
RenderPassAPI.instance.clear();
try {
GlassPaneRenderer.clear();
} catch (NoClassDefFoundError e) {
// nothing
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
renderBlockState.clear();
@@ -87,7 +87,7 @@ public class CustomAnimation implements Comparable<CustomAnimation> {
if (!pending.isEmpty()) {
try {
checkPendingAnimations();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
logger.error("%d remaining animations cleared", pending.size());
pending.clear();
@@ -219,7 +219,7 @@ public class FancyDial {
return instance;
}
instance.finish();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
@@ -410,7 +410,7 @@ public class FancyDial {
}
ImageIO.write(image, "png", path);
logger.info("wrote %dx%d %s", image.getWidth(), image.getHeight(), path.getPath());
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -143,7 +143,7 @@ public class FontUtils {
boolean[] isOverride = new boolean[charWidth.length];
try {
getCharWidthOverrides(filename, charWidthf, isOverride);
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
if (!isOverride[32]) {
@@ -47,7 +47,7 @@ abstract public class NBTRule {
} else {
return new Exact(tag, value);
}
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
return null;
}
@@ -204,7 +204,7 @@ abstract public class NBTRule {
if (result != null && cl.isAssignableFrom(result.getClass())) {
return cl.cast(result);
}
} catch (Throwable e) {}
} catch (Exception e) {}
return null;
}
@@ -104,7 +104,7 @@ public class ResourceList {
try {
zipFile = new ZipFile(jar);
scanZipFile(zipFile);
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
} finally {
MCPatcherUtils.close(zipFile);
@@ -55,7 +55,7 @@ abstract public class TexturePackChangeHandler implements Comparable<TexturePack
try {
logger.info("initializing %s...", handler.name);
handler.initialize();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
logger.severe("%s initialization failed", handler.name);
}
@@ -72,7 +72,7 @@ abstract public class TexturePackChangeHandler implements Comparable<TexturePack
try {
logger.info("refreshing %s...", handler.name);
handler.refresh();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
logger.severe("%s refresh failed", handler.name);
}
@@ -105,7 +105,7 @@ abstract public class TexturePackChangeHandler implements Comparable<TexturePack
try {
logger.info("refreshing %s (pre)...", handler.name);
handler.beforeChange();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
logger.severe("%s.beforeChange failed", handler.name);
}
@@ -123,7 +123,7 @@ abstract public class TexturePackChangeHandler implements Comparable<TexturePack
try {
logger.info("refreshing %s (post)...", handler.name);
handler.afterChange();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
logger.severe("%s.afterChange failed", handler.name);
}
@@ -133,7 +133,7 @@ abstract public class TexturePackChangeHandler implements Comparable<TexturePack
TexturePackChangeHandler handler = handlers.get(i);
try {
handler.afterChange2();
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
logger.severe("%s.afterChange2 failed", handler.name);
}
@@ -114,7 +114,7 @@ public abstract class ChunkRenderShaderBackend<T extends ChunkGraphicsState> imp
private static String getShaderSource(String path) {
try {
InputStream in = ShaderLoader.class.getResourceAsStream(path);
Throwable throwable = null;
Exception throwable = null;
String res;
try {
@@ -123,7 +123,7 @@ public abstract class ChunkRenderShaderBackend<T extends ChunkGraphicsState> imp
}
res = IOUtils.toString(in, StandardCharsets.UTF_8);
} catch (Throwable tr) {
} catch (Exception tr) {
throwable = tr;
throw tr;
} finally {
@@ -131,7 +131,7 @@ public abstract class ChunkRenderShaderBackend<T extends ChunkGraphicsState> imp
if (throwable != null) {
try {
in.close();
} catch (Throwable var12) {
} catch (Exception var12) {
throwable.addSuppressed(var12);
}
} else {
@@ -47,7 +47,7 @@ public class ShaderPackSelectionList extends IrisGuiSlot {
try {
names = Iris.getShaderpacksDirectoryManager().enumerate();
} catch (Throwable e) {
} catch (Exception e) {
Iris.logger.error("Error reading files while constructing selection UI", e);
// Not translating this since it's going to be seen very rarely,
@@ -67,7 +67,7 @@ public class CommentDirectiveParser {
try {
actual = testCase.get();
} catch (Throwable e) {
} catch (Exception e) {
System.err.println("Test \"" + name + "\" failed with an exception:");
e.printStackTrace();
@@ -67,8 +67,8 @@ public class PBRAtlasTexture extends AutoClosableAbstractTexture {
for (TextureAtlasSprite sprite : sprites.values()) {
try {
uploadSprite(sprite);
} catch (Throwable throwable) {
CrashReport crashReport = CrashReport.makeCrashReport(throwable, "Stitching texture atlas");
} catch (Exception e) {
CrashReport crashReport = CrashReport.makeCrashReport(e, "Stitching texture atlas");
CrashReportCategory crashReportCategory = crashReport.makeCategory("Texture being stitched together");
crashReportCategory.addCrashSection("Atlas path", id);
crashReportCategory.addCrashSection("Sprite", sprite);
@@ -97,7 +97,7 @@ public class PBRAtlasTexture extends AutoClosableAbstractTexture {
try {
upload(atlasWidth, atlasHeight, mipLevel, anisotropicFiltering);
return true;
} catch (Throwable t) {
} catch (Exception t) {
Iris.logger.error("Could not upload PBR texture", t);
return false;
}