From 71047762b3340f418ea47d20696a85a489c57966 Mon Sep 17 00:00:00 2001 From: Rohit Date: Wed, 13 Nov 2024 20:57:45 +0530 Subject: [PATCH 1/2] handle error for non-functions --- .../legend/pure/m3/exception/PureExecutionException.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/legend-pure-core/legend-pure-m3-core/src/main/java/org/finos/legend/pure/m3/exception/PureExecutionException.java b/legend-pure-core/legend-pure-m3-core/src/main/java/org/finos/legend/pure/m3/exception/PureExecutionException.java index bedf7b45a4..47adb22758 100644 --- a/legend-pure-core/legend-pure-m3-core/src/main/java/org/finos/legend/pure/m3/exception/PureExecutionException.java +++ b/legend-pure-core/legend-pure-m3-core/src/main/java/org/finos/legend/pure/m3/exception/PureExecutionException.java @@ -137,7 +137,14 @@ public T printPureStackTrace(T appendable, String indent, CoreInstance func = x.getValueForMetaPropertyToOne(M3Properties.func); if (func != null) { - FunctionDescriptor.writeFunctionDescriptor(appendable, func, false, processorSupport); + try + { + FunctionDescriptor.writeFunctionDescriptor(appendable, func, false, processorSupport); + } + catch (IllegalArgumentException e) + { + safeAppendable.append("NULL / TODO"); + } } else { From c9d3c228d07fa7e425c4ddcf4f6c0ff2f8ddf722 Mon Sep 17 00:00:00 2001 From: Rohit Date: Wed, 13 Nov 2024 21:10:07 +0530 Subject: [PATCH 2/2] add test --- .../api/TestFunctionExecutionStart.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/legend-pure-runtime/legend-pure-runtime-java-engine-interpreted/src/test/java/org/finos/legend/pure/runtime/java/interpreted/runtime/api/TestFunctionExecutionStart.java b/legend-pure-runtime/legend-pure-runtime-java-engine-interpreted/src/test/java/org/finos/legend/pure/runtime/java/interpreted/runtime/api/TestFunctionExecutionStart.java index d7cbaf02c8..38024fb473 100644 --- a/legend-pure-runtime/legend-pure-runtime-java-engine-interpreted/src/test/java/org/finos/legend/pure/runtime/java/interpreted/runtime/api/TestFunctionExecutionStart.java +++ b/legend-pure-runtime/legend-pure-runtime-java-engine-interpreted/src/test/java/org/finos/legend/pure/runtime/java/interpreted/runtime/api/TestFunctionExecutionStart.java @@ -129,4 +129,35 @@ public void testCallStackInExecutionExceptionPure() " assert(Boolean[1], String[1]):Boolean[1] <- resource:/platform/pure/essential/tests/assert.pure line:31 column:5\n" + " assert(Boolean[1], Function<{->String[1]}>[1]):Boolean[1] <- resource:/platform/pure/essential/tests/assert.pure line:26 column:5", trace); } + + @Test + public void testCallStackWithPropertyInExecutionExceptionPure() + { + compileTestSource("fromString.pure", + "###Pure\n" + + "Class Person { name: String[1]; }" + + " function go():Boolean[1]\n" + + " {\n" + + " nest().name;\n" + + " true;\n" + + " }\n" + + "function nest():Person[1]" + + "{" + + " fail();" + + " ^Person(name = 'John');" + + "}"); + + PureExecutionException e = Assert.assertThrows(PureExecutionException.class, () -> execute("go():Boolean[1]")); + String trace = e.printPureStackTrace(new StringBuilder(), " ", functionExecution.getProcessorSupport()).toString(); + Assert.assertEquals( + " 1: resource:/platform/pure/essential/tests/assert.pure line:26 column:5\n" + + "\n" + + " Full Stack:\n" + + " NULL / TODO <- resource:fromString.pure line:4 column:15\n" + + " nest():Person[1] <- resource:fromString.pure line:4 column:8\n" + + " fail():Boolean[1] <- resource:fromString.pure line:7 column:30\n" + + " assert(Boolean[1]):Boolean[1] <- resource:/platform/pure/essential/tests/fail.pure line:19 column:5\n" + + " assert(Boolean[1], String[1]):Boolean[1] <- resource:/platform/pure/essential/tests/assert.pure line:31 column:5\n" + + " assert(Boolean[1], Function<{->String[1]}>[1]):Boolean[1] <- resource:/platform/pure/essential/tests/assert.pure line:26 column:5", trace); + } }