From 83b0fb1f4db5ea980cf784929f1a663821de5b26 Mon Sep 17 00:00:00 2001 From: altrisi Date: Wed, 20 Apr 2022 13:29:31 +0200 Subject: [PATCH] Show local type in exception hover tooltips (#1397) --- src/main/java/carpet/script/CarpetScriptHost.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/carpet/script/CarpetScriptHost.java b/src/main/java/carpet/script/CarpetScriptHost.java index 0f515a33..78eae5b5 100644 --- a/src/main/java/carpet/script/CarpetScriptHost.java +++ b/src/main/java/carpet/script/CarpetScriptHost.java @@ -1059,13 +1059,15 @@ public class CarpetScriptHost extends ScriptHost continue; stringsToFormat.add(format + line.substring(lastPos, foundLocal.getKey())); stringsToFormat.add(format + foundLocal.getValue()); + Value val = context.variables.get(foundLocal.getValue()).evalValue(context); + String type = val.getTypeString(); String value; try { - value = context.variables.get(foundLocal.getValue()).evalValue(context).getPrettyString(); + value = val.getPrettyString(); } catch (StackOverflowError e) { value = "Exception while rendering variable, there seems to be a recursive reference in there"; } - stringsToFormat.add("^ Value of '" + foundLocal.getValue() + "' at position: \n" + stringsToFormat.add("^ Value of '" + foundLocal.getValue() + "' at position (" + type + "): \n" + value); lastPos = foundLocal.getKey() + foundLocal.getValue().length(); }