コード例 #1
0
  private ScriptErrorRaisedException processBshException(bsh.EvalError e, String script) {
    LogUtils.DEBUG("Beanshell error RAW message " + e.getMessage());
    String message = e.getMessage();
    int usefulInfoIndex = message.lastIndexOf("\' :");
    int lineNum = e.getErrorLineNumber();

    raiseEditor(lineNum);

    // String stackTrace = te.getScriptStackTrace();  // never seems to have any info??
    if (usefulInfoIndex > -1) {
      message = message.substring(usefulInfoIndex + 2);
    }
    if (e instanceof bsh.TargetError) {
      LogUtils.DEBUG("got instance of  TargetError");
      if (usefulInfoIndex == -1) {
        message = ((bsh.TargetError) e).getTarget().getMessage();
      }
      String wrappedException = "";
      String full = e.toString();
      int index = full.indexOf("Target exception:");
      if (index > -1) {
        String toParse = full.substring(index);
        LogUtils.DEBUG("About to parse " + toParse);
        StringTokenizer tokenizer = new StringTokenizer(full.substring(index), ":");
        if (tokenizer.countTokens() > 2) {
          LogUtils.DEBUG("First token = " + (String) tokenizer.nextElement());
          wrappedException = (String) tokenizer.nextElement();
          LogUtils.DEBUG("wrapped exception = = " + wrappedException);
        }
      }
      ScriptExceptionRaisedException se = new ScriptExceptionRaisedException(message);
      se.lineNum = lineNum;
      se.scriptName = script;
      se.exceptionType = wrappedException;
      se.language = "BeanShell";
      LogUtils.DEBUG("UnCaught Exception error: ");
      LogUtils.DEBUG("\tscript: " + script);
      LogUtils.DEBUG("\tline: " + lineNum);
      LogUtils.DEBUG("\twrapped exception: " + wrappedException);
      LogUtils.DEBUG("\tmessage: " + message);
      return se;
    } else {
      LogUtils.DEBUG("Error or ParseError Exception error: ");
      LogUtils.DEBUG("\tscript: " + script);
      LogUtils.DEBUG("\tline: " + lineNum);
      LogUtils.DEBUG("\tmessage: " + message);
      return new ScriptErrorRaisedException(message, null, script, "BeanShell", lineNum);
    }
  }