When an Error is found, return it instead of real value

This commit is contained in:
Jaroslav Tulach 2024-08-18 11:04:59 +02:00
parent 42da3aac0c
commit 2cc7ef516f
2 changed files with 5 additions and 6 deletions

View File

@ -318,6 +318,9 @@ public final class ReplDebuggerInstrument extends TruffleInstrument {
} catch (IOException ex) { } catch (IOException ex) {
logger.log(Level.SEVERE, line, ex); logger.log(Level.SEVERE, line, ex);
} }
if (InteropLibrary.getUncached().isException(b.getValue())) {
nodeState = new ReplExecutionEventNodeState(b.getValue(), nodeState.getLastScope());
}
} }
} }
exit(); exit();

View File

@ -4,7 +4,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -87,11 +86,8 @@ public class DebugServerWithScriptTest {
v v
"""; """;
var r = ContextUtils.evalModule(ctx, code, "ScriptTest.enso", "inspect"); var r = ContextUtils.evalModule(ctx, code, "ScriptTest.enso", "inspect");
assertTrue("Got array back: " + r, r.hasArrayElements()); assertTrue("Got error back: " + r, r.isException());
assertEquals("Got three elements", 3, r.getArraySize()); assertEquals("(Error: 2)", r.toString());
assertFalse("No error at 0th" + r, r.getArrayElement(0).isException());
assertTrue("Error 2 at 1st" + r, r.getArrayElement(1).isException());
assertTrue("Error 2 at 2nd " + r, r.getArrayElement(2).isException());
assertEquals("No output printed", "", out.toString()); assertEquals("No output printed", "", out.toString());
assertThat( assertThat(
"Stderr contains some errors", "Stderr contains some errors",