Ejemplo n.º 1
0
 public GremlinScriptEngine() {
   this.context = new GremlinScriptContext();
   try {
     this.eval(new FileReader(GREMLIN_RC_FILE), this.context);
   } catch (FileNotFoundException e) {
   } catch (IOException e) {
     throw new RuntimeException(e.getMessage());
   }
 }
Ejemplo n.º 2
0
  public void reportScriptFileError(File script, ScriptException e) {
    String dir = script.getParent();
    String name = script.getName() + ".error.log";
    if (dir != null) {
      File file = new File(dir + "/" + name);
      FileOutputStream fos = null;
      try {
        if (!file.exists()) {
          file.createNewFile();
        }

        fos = new FileOutputStream(file);
        String errorHeader =
            "Error on: "
                + file.getCanonicalPath()
                + "\r\nLine: "
                + e.getLineNumber()
                + " - Column: "
                + e.getColumnNumber()
                + "\r\n\r\n";
        fos.write(errorHeader.getBytes());
        fos.write(e.getMessage().getBytes());
        _log.warn(
            "Failed executing script: "
                + script.getAbsolutePath()
                + ". See "
                + file.getName()
                + " for details.");
      } catch (IOException ioe) {
        _log.warn(
            "Failed executing script: "
                + script.getAbsolutePath()
                + "\r\n"
                + e.getMessage()
                + "Additionally failed when trying to write an error report on script directory. Reason: "
                + ioe.getMessage());
        ioe.printStackTrace();
      } finally {
        try {
          fos.close();
        } catch (Exception e1) {
        }
      }
    } else {
      _log.warn(
          "Failed executing script: "
              + script.getAbsolutePath()
              + "\r\n"
              + e.getMessage()
              + "Additionally failed when trying to write an error report on script directory.");
    }
  }