Report stack traces through the logger (#1050)

This commit is contained in:
altrisi authored and GitHub committed 2021-10-11 03:37:30 -03:00
1 parent 4a580a5a42
commit 7486670918
7 files changed
+16 -17

No files matched your search

@@ -6,9 +6,9 @@ import carpet.helpers.EntityPlayerActionPack;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.network.ServerPlayerInteractionManager;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -16,7 +16,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ServerPlayerEntity.class) @Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerEntityMixin implements ServerPlayerEntityInterface public abstract class ServerPlayerEntityMixin implements ServerPlayerEntityInterface
{ {
@Unique
public EntityPlayerActionPack actionPack; public EntityPlayerActionPack actionPack;
@Override
public EntityPlayerActionPack getActionPack() public EntityPlayerActionPack getActionPack()
{ {
return actionPack; return actionPack;
@@ -41,15 +43,11 @@ public abstract class ServerPlayerEntityMixin implements ServerPlayerEntityInter
} }
catch (StackOverflowError soe) catch (StackOverflowError soe)
{ {
CarpetSettings.LOG.fatal("Caused stack overflow when performing player action"); CarpetSettings.LOG.fatal("Caused stack overflow when performing player action", soe);
} }
catch (Throwable exc) catch (Throwable exc)
{ {
CarpetSettings.LOG.fatal("Error executing player tasks "+ exc.getMessage()); CarpetSettings.LOG.fatal("Error executing player tasks", exc);
exc.printStackTrace();
} }
} }
} }
@@ -74,8 +74,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
} }
catch (Exception booboo) catch (Exception booboo)
{ {
CarpetSettings.LOG.error("Unknown Exception while plopping structure: "+booboo); CarpetSettings.LOG.error("Unknown Exception while plopping structure: "+booboo, booboo);
booboo.printStackTrace();
return false; return false;
} }
finally finally
@@ -1174,7 +1174,7 @@ public class CarpetEventServer
} }
catch (NullPointerException | InvalidCallbackException | IntegrityException error) catch (NullPointerException | InvalidCallbackException | IntegrityException error)
{ {
CarpetScriptServer.LOG.error("Got exception: "+error.getMessage()); CarpetScriptServer.LOG.error("Got exception when running event call ", error);
return CallbackResult.FAIL; return CallbackResult.FAIL;
} }
} }
+1 -1
View File
@@ -377,7 +377,7 @@ public class Expression
if (exc instanceof ResolvedException) if (exc instanceof ResolvedException)
return exc; return exc;
// unexpected really - should be caught earlier and converted to InternalExpressionException // unexpected really - should be caught earlier and converted to InternalExpressionException
exc.printStackTrace(); CarpetSettings.LOG.error("Unexpected exception while running Scarpet code", exc);
return new ExpressionException(c, e, token, "Error while evaluating expression: "+exc); return new ExpressionException(c, e, token, "Error while evaluating expression: "+exc);
} }
+2 -1
View File
@@ -1,5 +1,6 @@
package carpet.script.value; package carpet.script.value;
import carpet.CarpetSettings;
import carpet.script.exception.InternalExpressionException; import carpet.script.exception.InternalExpressionException;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
@@ -42,7 +43,7 @@ public abstract class Value implements Comparable<Value>, Cloneable
catch (CloneNotSupportedException e) catch (CloneNotSupportedException e)
{ {
// should not happen // should not happen
e.printStackTrace(); CarpetSettings.LOG.catching(e);
throw new InternalExpressionException("Variable of type "+getTypeString()+" is not cloneable. Tell gnembon about it, this shoudn't happen"); throw new InternalExpressionException("Variable of type "+getTypeString()+" is not cloneable. Tell gnembon about it, this shoudn't happen");
} }
copy.boundVariable = var; copy.boundVariable = var;
@@ -321,8 +321,7 @@ public class SettingsManager
} }
catch (IOException e) catch (IOException e)
{ {
e.printStackTrace(); CarpetSettings.LOG.error("[CM]: failed write "+identifier+".conf config file", e);
CarpetSettings.LOG.error("[CM]: failed write "+identifier+".conf config file");
} }
///todo is it really needed? resendCommandTree(); ///todo is it really needed? resendCommandTree();
} }
@@ -480,7 +479,7 @@ public class SettingsManager
} }
catch (IOException e) catch (IOException e)
{ {
e.printStackTrace(); CarpetSettings.LOG.error("Exception while loading Carpet rules from config", e);
return new ConfigReadResult(new HashMap<>(), false); return new ConfigReadResult(new HashMap<>(), false);
} }
} }
@@ -34,6 +34,8 @@ import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.gen.feature.StructureFeature;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import carpet.CarpetSettings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@@ -460,7 +462,7 @@ public class SpawnReporter
} }
catch (Exception exception) catch (Exception exception)
{ {
exception.printStackTrace(); CarpetSettings.LOG.warn("Exception while creating mob for spawn reporter", exception);
return rep; return rep;
} }
@@ -517,7 +519,7 @@ public class SpawnReporter
} }
catch (Exception exception) catch (Exception exception)
{ {
exception.printStackTrace(); CarpetSettings.LOG.warn("Exception while creating mob for spawn reporter", exception);
return rep; return rep;
} }
} }