Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log details when to_display_text invocation fails #11025

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.enso.interpreter.test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
Expand Down Expand Up @@ -146,19 +148,19 @@ private static void assertLessArguments(String msg, Function<Object[], Atom> fac
var zero = factory.apply(new Object[0]);
fail("Expecting exception: " + zero);
} catch (PanicException e) {
assertEquals(msg + " no arguments", "Arity_Error.Error", e.getMessage());
assertThat(msg + " no arguments", e.getMessage(), containsString("Arity_Error"));
}
try {
var one = factory.apply(new Object[] {"a"});
fail("Expecting exception: " + one);
} catch (PanicException e) {
assertEquals(msg + " one argument", "Arity_Error.Error", e.getMessage());
assertThat(msg + " one argument", e.getMessage(), containsString("Arity_Error"));
}
try {
var two = factory.apply(new Object[] {"a", "b"});
fail("Expecting exception: " + two);
} catch (PanicException e) {
assertEquals(msg + " two arguments", "Arity_Error.Error", e.getMessage());
assertThat(msg + " two arguments", e.getMessage(), containsString("Arity_Error"));
}
return null;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,7 @@ class ReplTest
executor.exit()
}
eval(code)
val errorMsg =
"Compile_Error.Error"
evalResult.left.value.getMessage shouldEqual errorMsg
evalResult.left.value.getMessage should include ("Compile_Error")
}

"handle errors gracefully (pretty print)" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.oracle.truffle.api.library.ExportMessage;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.source.SourceSection;
import java.util.logging.Level;
import org.enso.interpreter.node.BaseNode.TailStatus;
import org.enso.interpreter.node.callable.IndirectInvokeMethodNode;
import org.enso.interpreter.node.callable.InvokeCallableNode.ArgumentsExecutionMode;
Expand Down Expand Up @@ -81,9 +82,13 @@ public String getMessage() {
private String computeMessage() {
String msg;
InteropLibrary library = InteropLibrary.getUncached();
Object info = null;
try {
msg = library.asString(library.getExceptionMessage(this));
info = library.getExceptionMessage(this);
msg = library.asString(info);
} catch (AssertionError | UnsupportedMessageException e) {
var ctx = EnsoContext.get(null);
ctx.getLogger().log(Level.WARNING, "Cannot convert " + info + " to string", e);
msg = TypeToDisplayTextNode.getUncached().execute(payload);
}
cacheMessage = msg;
Expand Down Expand Up @@ -153,6 +158,7 @@ static Object handleExceptionMessage(
try {
return Text.create(strings.asString(text));
} catch (UnsupportedMessageException e) {
ctx.getLogger().log(Level.WARNING, "Cannot convert " + text + " to string", e);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hubertp, is this the right way to dump additional info into CI log including:

  • a message
  • value of text
  • exception e with its stacktrace

If not, can you please update the line to dump such an info so it appears in the CI log when the error happens?

return Text.create(typeToDisplayTextNode.execute(payload));
}
}
Expand Down
Loading