org.mozilla.javascript.EcmaError.sourceName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 JavaScript  
字(2.8k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中org.mozilla.javascript.EcmaError.sourceName()方法的一些代码示例,展示了EcmaError.sourceName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EcmaError.sourceName()方法的具体详情如下:
包路径:org.mozilla.javascript.EcmaError
类名称:EcmaError
方法名:sourceName

EcmaError.sourceName介绍

暂无

代码示例

代码示例来源:origin: com.sun.phobos/phobos-rhino

/**
 * @deprecated Use {@link RhinoException#sourceName()} from the super class.
 */
public String getSourceName()
{
  return sourceName();
}

代码示例来源:origin: rhino/js

/**
 * @deprecated Use {@link RhinoException#sourceName()} from the super class.
 */
public String getSourceName()
{
  return sourceName();
}

代码示例来源:origin: ro.isdc.wro4j/rhino

/**
 * @deprecated Use {@link RhinoException#sourceName()} from the super class.
 */
public String getSourceName()
{
  return sourceName();
}

代码示例来源:origin: io.apigee/rhino

/**
 * @deprecated Use {@link RhinoException#sourceName()} from the super class.
 */
public String getSourceName()
{
  return sourceName();
}

代码示例来源:origin: com.github.tntim96/rhino

/**
 * @deprecated Use {@link RhinoException#sourceName()} from the super class.
 */
public String getSourceName()
{
  return sourceName();
}

代码示例来源:origin: geogebra/geogebra

/**
 * @deprecated Use {@link RhinoException#sourceName()} from the super class.
 */
@Deprecated
public String getSourceName()
{
  return sourceName();
}

代码示例来源:origin: ca.carleton.gcrc/nunaliit2-javascript

public Object evaluateJavascript(String javascript) throws Exception {
  try {
    Object result = cx.evaluateString(scope, javascript, "main", 1, null);
    return result;
    
  } catch(EcmaError e) {
    for(JavascriptRunnerListener listener : listeners){
      listener.runtimeError(e.details(), e.sourceName(), e.lineNumber());
    }
    throw e;
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-flowscript-impl

public Location getLocation(Object obj, String description) {
    if (obj instanceof EcmaError) {
      EcmaError ex = (EcmaError)obj;
      if (ex.sourceName() != null) {
        return new LocationImpl(ex.getName(), ex.sourceName(), ex.lineNumber(), ex.columnNumber());
      } else {
        return Location.UNKNOWN;
      }

    } else if (obj instanceof JavaScriptException) {
      JavaScriptException ex = (JavaScriptException)obj;
      if (ex.sourceName() != null) {
        return new LocationImpl(description, ex.sourceName(), ex.lineNumber(), -1);
      } else {
        return Location.UNKNOWN;
      }
    }
    
    return null;
  } 
};

代码示例来源:origin: org.geoserver.script/gs-script-js

@Override
public Object eval(Reader reader, ScriptContext context) throws ScriptException {
  String filename = (String) get(ScriptEngine.FILENAME);
  if (filename == null) {
    filename = "<Unknown Source>";
  }
  Object result;
  EngineScope scope = new EngineScope(context);
  Global global = getGlobal();
  scope.setParentScope(global);
  scope.setPrototype(global);
  Context cx = enterContext();
  try {
    scope.put("exports", scope, cx.newObject(global));
    result = cx.evaluateReader(scope, reader, filename, 1, null);
  } catch (EcmaError e) {
    throw new ScriptException(
        e.getMessage(), e.sourceName(), e.lineNumber(), e.columnNumber());
  } catch (Exception e) {
    throw new ScriptException(e);
  } finally {
    Context.exit();
  }
  return result;
}

相关文章