code: public static String getMessage(PyException e) {
          if (e.getMessage() != null) {
              return e.getMessage();
          } else {
              StringWriter stringWriter = new StringWriter();
              e.printStackTrace(new PrintWriter(stringWriter));
              return stringWriter.toString();
          }
      }
docs: Gets message of a PyException.
  If internal message is null, uses printStackTrace() method to build message.
  
  @param e PyException
  @return message string