use of com.oracle.truffle.api.interop.ExceptionType in project graal by oracle.
the class TruffleExceptionTest method testExceptionFromPolyglotExceptionConstructorImpl.
private void testExceptionFromPolyglotExceptionConstructorImpl(ExceptionType type, boolean internal, TruffleExceptionImpl.MessageKind... failOn) {
setupEnv(Context.create(), new ProxyLanguage() {
@Override
protected CallTarget parse(TruffleLanguage.ParsingRequest request) throws Exception {
ThrowNode throwNode = new ThrowNode((n) -> new TruffleExceptionImpl("test", n, type, new InjectException(failOn)));
return new TestRootNode(languageInstance, "test", "unnamed", throwNode).getCallTarget();
}
});
assertFails(() -> context.eval(ProxyLanguage.ID, "Test"), PolyglotException.class, (pe) -> {
Assert.assertEquals(internal, pe.isInternalError());
});
}
use of com.oracle.truffle.api.interop.ExceptionType in project graal by oracle.
the class TruffleExceptionTest method testExceptionFromCreateContext.
@Test
public void testExceptionFromCreateContext() {
String message = "Failed to create";
ExceptionType type = ExceptionType.EXIT;
assertFails(() -> setupEnv(Context.create(), new ProxyLanguage() {
@Override
protected LanguageContext createContext(Env env) {
throw new TruffleExceptionImpl(message, null, type, null);
}
}), PolyglotException.class, (pe) -> {
Assert.assertEquals(message, pe.getMessage());
Assert.assertTrue(pe.isExit());
Assert.assertFalse(pe.isInternalError());
Assert.assertEquals(0, pe.getExitStatus());
Assert.assertNull(pe.getGuestObject());
});
}
Aggregations