More info when we fail to log AssertError (#11113)

Motivation:
```
Caused by: java.lang.AssertionError: No polyglot context is entered. A language or context reference must not be used if there is no polyglot context entered.
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotFastThreadLocals.assertValidGet(PolyglotFastThreadLocals.java:481)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotFastThreadLocals$ContextReferenceImpl.get(PolyglotFastThreadLocals.java:513)
 	at org.enso.runtime/org.enso.interpreter.runtime.EnsoContext.get(EnsoContext.java:246)
	at org.enso.runtime/org.enso.interpreter.runtime.error.PanicException.computeMessage(PanicException.java:90)
```
This commit is contained in:
Hubert Plociniczak 2024-09-17 23:20:14 +02:00 committed by GitHub
parent 567910ae14
commit 862100c7c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -87,9 +87,15 @@ public final class PanicException extends AbstractTruffleException implements En
info = library.getExceptionMessage(this);
msg = library.asString(info);
} catch (AssertionError | UnsupportedMessageException e) {
try {
var ctx = EnsoContext.get(null);
ctx.getLogger().log(Level.WARNING, "Cannot convert " + info + " to string", e);
msg = TypeToDisplayTextNode.getUncached().execute(payload);
} catch (AssertionError assertionError) {
throw new AssertionError(
"Failed to log failed conversion of " + info + " to string and payload " + payload,
assertionError);
}
}
cacheMessage = msg;
return msg;