mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
add multiline support pythonErrorIn method
This commit is contained in:
parent
9eeaf49f07
commit
e6741348c9
2 changed files with 32 additions and 2 deletions
|
|
@ -150,8 +150,17 @@ public class PythonInterpreter extends Interpreter {
|
|||
* @return true if syntax error or exception has happened
|
||||
*/
|
||||
private boolean pythonErrorIn(String output) {
|
||||
Matcher errorMatcher = errorInLastLine.matcher(output);
|
||||
return errorMatcher.find();
|
||||
boolean isError = false;
|
||||
String[] outputMultiline = output.split("\n");
|
||||
Matcher errorMatcher;
|
||||
for (String row : outputMultiline) {
|
||||
errorMatcher = errorInLastLine.matcher(row);
|
||||
if (errorMatcher.find() == true) {
|
||||
isError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isError;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -218,4 +218,25 @@ public class PythonInterpreterTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkMultiRowErrorFails() {
|
||||
PythonInterpreter pythonInterpreter = new PythonInterpreter(
|
||||
PythonInterpreterTest.getPythonTestProperties()
|
||||
);
|
||||
pythonInterpreter.open();
|
||||
String codeRaiseException = "raise Exception(\"test exception\")";
|
||||
InterpreterResult ret = pythonInterpreter.interpret(codeRaiseException, null);
|
||||
|
||||
assertNotNull("Interpreter result for raise exception is Null", ret);
|
||||
|
||||
assertEquals(InterpreterResult.Code.ERROR, ret.code());
|
||||
assertTrue(ret.message().length() > 0);
|
||||
|
||||
assertNotNull("Interpreter result for text is Null", ret);
|
||||
String codePrintText = "print (\"Exception(\\\"test exception\\\")\")";
|
||||
ret = pythonInterpreter.interpret(codePrintText, null);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
|
||||
assertTrue(ret.message().length() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue