Skip to content

Commit d138c42

Browse files
committed
[GR-15169] Propagate messages from parser to the user.
1 parent 98dac2d commit d138c42

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/PythonParserImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ public String unescapeJavaString(String str) {
258258

259259
private static PException handleParserError(ParserErrorCallback errors, Source source, Exception e) {
260260
SourceSection section = PythonErrorStrategy.getPosition(source, e);
261-
throw errors.raiseInvalidSyntax(source, section);
261+
// from parser we are getting RuntimeExceptions
262+
String message = e instanceof RuntimeException && e.getMessage() != null ? e.getMessage() : "invalid syntax";
263+
throw errors.raiseInvalidSyntax(source, section, message);
262264
}
263265
}

0 commit comments

Comments
 (0)