feat: improve print stack trace

This commit is contained in:
Reider745
2026-04-19 10:59:55 +03:00
parent 0638a71ad2
commit 97d49c526f
2 changed files with 14 additions and 4 deletions
@@ -34,6 +34,7 @@ import com.zhekasmirnov.innercore.ui.LoadingUI;
import com.zhekasmirnov.innercore.utils.FileTools; import com.zhekasmirnov.innercore.utils.FileTools;
import com.zhekasmirnov.mcpe161.InnerCore; import com.zhekasmirnov.mcpe161.InnerCore;
import org.json.JSONObject; import org.json.JSONObject;
import org.mozilla.javascript.Context;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@@ -52,7 +53,7 @@ import java.util.zip.ZipFile;
public class InnerCoreServer { public class InnerCoreServer {
public enum MethodHandling { public enum MethodHandling {
NONE, DEBUG, WARNING, RAISE; NONE, DEBUG, WARNING, TRACE, RAISE;
} }
public static final int PROTOCOL = 422; public static final int PROTOCOL = 422;
@@ -659,6 +660,7 @@ public class InnerCoreServer {
case DEBUG -> Logger.message(message); case DEBUG -> Logger.message(message);
case WARNING -> Logger.warning(message); case WARNING -> Logger.warning(message);
case RAISE -> throw new RuntimeException(message); case RAISE -> throw new RuntimeException(message);
case TRACE -> printStackTrace(message);
default -> throw new UnsupportedOperationException(); default -> throw new UnsupportedOperationException();
} }
} }
@@ -681,11 +683,19 @@ public class InnerCoreServer {
+ "), which is why you're reading this right now"); + "), which is why you're reading this right now");
} }
public static void printStackTrace() { public static void warning(String message) {
handleUnsupportedMethod("Warning: " + message);
}
public static void printStackTrace(String message) {
try { try {
throw new RuntimeException("Aboba"); throw Context.reportRuntimeError("Error");
} catch (Exception e) { } catch (Exception e) {
System.out.println(ICLog.getStackTrace(e)); System.out.println(ICLog.getStackTrace(e));
} }
} }
public static void printStackTrace() {
printStackTrace("Trace");
}
} }
@@ -75,7 +75,7 @@ public class EntityMethod {
} }
if (entityUid != 0 && InnerCoreServer.isDeveloperMode()) { if (entityUid != 0 && InnerCoreServer.isDeveloperMode()) {
Logger.warning("NativeAPI", "Unknown entityUid=" + entityUid + ", aborting requested action!"); InnerCoreServer.warning("Unknown entityUid=" + entityUid + ", aborting requested action!");
} }
return null; return null;