@Test public void testException() { String id = null; try { throw new RuntimeException("Hello World"); } catch (Exception e) { id = "r" + gateway.putNewObject(e); } String inputCommand = id + "\ne\n"; try { command.execute("p", new BufferedReader(new StringReader(inputCommand)), writer); System.out.println("DEBUG!!!" + sWriter.toString()); assertTrue(sWriter.toString().startsWith("!ysjava.lang.RuntimeException: Hello World")); } catch (Exception e) { e.printStackTrace(); fail(); } }
@Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { String returnCommand = null; Throwable exception = (Throwable) Protocol.getObject(reader.readLine(), this.gateway); reader.readLine(); String stackTrace = Protocol.getThrowableAsString(exception); ReturnObject rObject = ReturnObject.getPrimitiveReturnObject(stackTrace); returnCommand = Protocol.getOutputCommand(rObject); logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); }
ExceptionCommand extends AbstractCommand { @Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { String returnCommand = null; Throwable exception = (Throwable) Protocol.getObject(reader.readLine(), this.gateway); reader.readLine(); String stackTrace = Protocol.getThrowableAsString(exception); ReturnObject rObject = ReturnObject.getPrimitiveReturnObject(stackTrace); returnCommand = Protocol.getOutputCommand(rObject); logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); } }
ExceptionCommand extends AbstractCommand { @Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { String returnCommand = null; Throwable exception = (Throwable) Protocol.getObject(reader.readLine(), this.gateway); reader.readLine(); String stackTrace = Protocol.getThrowableAsString(exception); ReturnObject rObject = ReturnObject.getPrimitiveReturnObject(stackTrace); returnCommand = Protocol.getOutputCommand(rObject); logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); } ExceptionCommand(); }
ExceptionCommand extends AbstractCommand { @Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { String returnCommand = null; Throwable exception = (Throwable) Protocol.getObject(reader.readLine(), this.gateway); reader.readLine(); String stackTrace = Protocol.getThrowableAsString(exception); ReturnObject rObject = ReturnObject.getPrimitiveReturnObject(stackTrace); returnCommand = Protocol.getOutputCommand(rObject); logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); } ExceptionCommand(); @Override void execute(String commandName, BufferedReader reader, BufferedWriter writer); }
ExceptionCommand extends AbstractCommand { @Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { String returnCommand = null; Throwable exception = (Throwable) Protocol.getObject(reader.readLine(), this.gateway); reader.readLine(); String stackTrace = Protocol.getThrowableAsString(exception); ReturnObject rObject = ReturnObject.getPrimitiveReturnObject(stackTrace); returnCommand = Protocol.getOutputCommand(rObject); logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); } ExceptionCommand(); @Override void execute(String commandName, BufferedReader reader, BufferedWriter writer); final static String EXCEPTION_COMMAND_NAME; }