-
Notifications
You must be signed in to change notification settings - Fork 323
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
Unhandled Java Exceptions not handled in same way as Enso panics in GUI #11881
Labels
Comments
The problem is at Line 272 in 269354e
while |
With these changes: diff --git engine/runtime-instrument-common/src/main/java/org/enso/interpreter/service/ExecutionService.java engine/runtime-instrument-common/src/main/java/org/enso/interpreter/service/ExecutionService.java
index 7e56ca4b6f..8b86a4a067 100644
--- engine/runtime-instrument-common/src/main/java/org/enso/interpreter/service/ExecutionService.java
+++ engine/runtime-instrument-common/src/main/java/org/enso/interpreter/service/ExecutionService.java
@@ -532,25 +532,26 @@ public final class ExecutionService {
* @param panic the panic to display.
* @return a human-readable version of its contents.
*/
- public String getExceptionMessage(PanicException panic) {
+ public String getExceptionMessage(AbstractTruffleException panic) {
var iop = InteropLibrary.getUncached();
var p = context.getThreadManager().enter();
+ var payload = panic instanceof PanicException pe ? pe.getPayload() : panic;
try {
// Invoking a member on an Atom that does not have a method `to_display_text` will not
// contrary to what is
// expected from the documentation, throw an `UnsupportedMessageException`.
// Instead it will crash with some internal assertion deep inside runtime. Hence the check.
- if (iop.isMemberInvocable(panic.getPayload(), "to_display_text")) {
- return iop.asString(iop.invokeMember(panic.getPayload(), "to_display_text"));
+ if (iop.isMemberInvocable(payload, "to_display_text")) {
+ return iop.asString(iop.invokeMember(payload, "to_display_text"));
} else throw UnsupportedMessageException.create();
} catch (UnsupportedMessageException
| ArityException
| UnknownIdentifierException
| UnsupportedTypeException e) {
- return TypeToDisplayTextNode.getUncached().execute(panic.getPayload());
+ return TypeToDisplayTextNode.getUncached().execute(payload);
} catch (Throwable e) {
if (iop.isException(e)) {
- return TypeToDisplayTextNode.getUncached().execute(panic.getPayload());
+ return TypeToDisplayTextNode.getUncached().execute(payload);
} else {
throw e;
}
diff --git engine/runtime-instrument-id-execution/src/main/java/org/enso/interpreter/instrument/id/execution/IdExecutionInstrument.java engine/runtime-instrument-id-execution/src/main/java/org/enso/interpreter/instrument/id/execution/IdExecutionInstrument.java
index bb4a5ae65d..9734c5c87c 100644
--- engine/runtime-instrument-id-execution/src/main/java/org/enso/interpreter/instrument/id/execution/IdExecutionInstrument.java
+++ engine/runtime-instrument-id-execution/src/main/java/org/enso/interpreter/instrument/id/execution/IdExecutionInstrument.java
@@ -35,7 +35,6 @@ import org.enso.interpreter.runtime.callable.function.Function;
import org.enso.interpreter.runtime.control.TailCallException;
import org.enso.interpreter.runtime.data.text.Text;
import org.enso.interpreter.runtime.error.DataflowError;
-import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.error.PanicSentinel;
import org.enso.interpreter.runtime.instrument.Timer;
import org.enso.interpreter.runtime.state.ExecutionEnvironment;
@@ -268,10 +267,8 @@ public class IdExecutionInstrument extends TruffleInstrument implements IdExecut
public void onReturnExceptional(VirtualFrame frame, Throwable exception) {
if (exception instanceof TailCallException) {
onTailCallReturn(exception, Function.ArgumentsHelper.getState(frame.getArguments()));
- } else if (exception instanceof PanicException panicException) {
- onReturnValue(frame, new PanicSentinel(panicException, context.getInstrumentedNode()));
- } else if (exception instanceof AbstractTruffleException) {
- onReturnValue(frame, exception);
+ } else if (exception instanceof AbstractTruffleException ex) {
+ onReturnValue(frame, new PanicSentinel(ex, context.getInstrumentedNode()));
}
}
diff --git engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicSentinel.java engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicSentinel.java
index 2d64b1f5d2..301eb96f82 100644
--- engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicSentinel.java
+++ engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicSentinel.java
@@ -14,7 +14,7 @@ import org.enso.interpreter.runtime.library.dispatch.TypesLibrary;
*/
@ExportLibrary(TypesLibrary.class)
public final class PanicSentinel extends AbstractTruffleException {
- final PanicException panic;
+ private final AbstractTruffleException panic;
/**
* Create an instance of the panic sentinel, wrapping the provided panic.
@@ -22,7 +22,7 @@ public final class PanicSentinel extends AbstractTruffleException {
* @param panic the panic to wrap
* @param location the location from where the sentinel was thrown
*/
- public PanicSentinel(PanicException panic, Node location) {
+ public PanicSentinel(AbstractTruffleException panic, Node location) {
super(location);
this.panic = panic;
}
@@ -32,7 +32,7 @@ public final class PanicSentinel extends AbstractTruffleException {
*
* @return the underlying panic object
*/
- public PanicException getPanic() {
+ public AbstractTruffleException getPanic() {
return panic;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Methods called on the Java exceptions result in a method not found error as opposed to repeating the panic.
The text was updated successfully, but these errors were encountered: