diff --git a/ownlang-parser/src/main/java/com/annimon/ownlang/lib/ClassInstanceValue.java b/ownlang-parser/src/main/java/com/annimon/ownlang/lib/ClassInstanceValue.java index 9a2ff76..3def100 100644 --- a/ownlang-parser/src/main/java/com/annimon/ownlang/lib/ClassInstanceValue.java +++ b/ownlang-parser/src/main/java/com/annimon/ownlang/lib/ClassInstanceValue.java @@ -40,7 +40,9 @@ public class ClassInstanceValue implements Value { public void callConstructor(Value[] args) { if (constructor != null) { + CallStack.enter("class " + className, constructor, null); constructor.execute(args); + CallStack.exit(); } } @@ -64,18 +66,18 @@ public class ClassInstanceValue implements Value { @Override public int asInt() { - throw new TypeException("Cannot cast class to integer"); + throw new TypeException("Cannot cast class " + className + " to integer"); } @Override public double asNumber() { - throw new TypeException("Cannot cast class to integer"); + throw new TypeException("Cannot cast class " + className + " to number"); } @Override public String asString() { if (toString != null) { - return toString.execute(new Value[] {}).asString(); + return toString.execute(new Value[0]).asString(); } return className + "@" + thisMap; }