当前位置: 首页>>代码示例>>Java>>正文


Java RhinoException.details方法代码示例

本文整理汇总了Java中org.mozilla.javascript.RhinoException.details方法的典型用法代码示例。如果您正苦于以下问题:Java RhinoException.details方法的具体用法?Java RhinoException.details怎么用?Java RhinoException.details使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mozilla.javascript.RhinoException的用法示例。


在下文中一共展示了RhinoException.details方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertException

import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
/**
 * Converts general exception to more readable format.
 * 
 * @param ex
 * @return
 */
protected CrosstabException convertException( Exception ex )
{
	if ( ex instanceof RhinoException )
	{
		RhinoException e = (RhinoException) ex;
		String lineSource = e.lineSource( );
		String details = e.details( );
		String lineNumber = String.valueOf( e.lineNumber( ) );
		if ( lineSource == null )
			lineSource = "";//$NON-NLS-1$
		return new CrosstabException( Messages.getString( "CrosstabScriptHandler.error.javascript", //$NON-NLS-1$
				new Object[]{
						details, lineNumber, lineSource
				} ) );
	}
	else
	{
		return new CrosstabException( ex );
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:27,代码来源:CrosstabScriptHandler.java

示例2: convertException

import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
/**
 * Converts general exception to more readable format.
 * 
 * @param ex
 * @return
 */
protected ChartException convertException( Exception ex )
{
	if ( ex instanceof RhinoException )
	{
		RhinoException e = (RhinoException) ex;
		String lineSource = e.lineSource( );
		String details = e.details( );
		String lineNumber = String.valueOf( e.lineNumber( ) );
		if ( lineSource == null )
			lineSource = "";//$NON-NLS-1$
		return new ChartException( ChartEnginePlugin.ID,
				ChartException.SCRIPT,
				"exception.javascript.error", //$NON-NLS-1$
				new Object[]{
						details, lineNumber, lineSource
				},
				Messages.getResourceBundle( csc.getULocale( ) ),
				e );
	}
	/*
	 * TODO convert those exceptions too else if ( ex instanceof
	 * IllegalAccessException ) {} else if ( ex instanceof
	 * InstantiationException ) {} else if ( ex instanceof
	 * InvocationTargetException ) { }
	 */
	else
		return new ChartException( ChartEnginePlugin.ID,
				ChartException.SCRIPT,
				ex );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:37,代码来源:AbstractScriptHandler.java

示例3: executeRhinoScript

import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
private Object executeRhinoScript() {
    Context cx = CTX_FACTORY.enterContext();

    try {
        cx.setOptimizationLevel(optLevel);

        Scriptable scope = cx.initStandardObjects();
        for (String harnessFile : harnessFiles) {
            if (!HARNESS_SCRIPT_CACHE.get(optLevel).containsKey(harnessFile)) {
                HARNESS_SCRIPT_CACHE.get(optLevel).put(
                    harnessFile,
                    cx.compileReader(new FileReader("test262/harness/" + harnessFile), "test262/harness/" + harnessFile, 1, null)
                );
            }
            HARNESS_SCRIPT_CACHE.get(optLevel).get(harnessFile).exec(cx, scope);
        }

        String str = jsFileStr;
        if (useStrict) { // taken from test262.py
            str = "\"use strict\";\nvar strict_mode = true;\n" + jsFileStr;
        }

        Object result = cx.evaluateString(scope, str, jsFilePath.replaceAll("\\\\", "/"), 1, null);

        if (errorType != EcmaErrorType.NONE) {
            fail(String.format("failed negative test. expected error: %s", errorType));
            return null;
        }

        return result;
    } catch (RhinoException ex) {
        if (errorType == EcmaErrorType.NONE) {
            fail(String.format("%s%n%s", ex.getMessage(), ex.getScriptStackTrace()));
        } else {
            if (errorType == EcmaErrorType.ANY) {
                // passed
            } else {
                String exceptionName;
                if (ex instanceof EvaluatorException) {
                    exceptionName = "SyntaxError";
                } else {
                    exceptionName = ex.details();
                    if (exceptionName.contains(":")) {
                        exceptionName = exceptionName.substring(0, exceptionName.indexOf(":"));
                    }
                }
                assertEquals(ex.details(), errorType.name(), exceptionName);
            }
        }
        return null;
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        Context.exit();
    }
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:57,代码来源:Test262SuiteTest.java

示例4: parse

import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public ParseResult parse(RSyntaxDocument doc, String style) {

	astRoot = null;
	result.clearNotices();
	// Always spell check all lines, for now.
	Element root = doc.getDefaultRootElement();
	int lineCount = root.getElementCount();
	result.setParsedLines(0, lineCount - 1);

	DocumentReader r = new DocumentReader(doc);
	ErrorCollector errorHandler = new ErrorCollector();
	CompilerEnvirons env = createCompilerEnvironment(errorHandler, langSupport);
	long start = System.currentTimeMillis();
	try {
		Parser parser = new Parser(env);
		astRoot = parser.parse(r, null, 0);
		long time = System.currentTimeMillis() - start;
		result.setParseTime(time);
	} catch (IOException ioe) { // Never happens
		result.setError(ioe);
		ioe.printStackTrace();
	} catch (RhinoException re) {
		// Shouldn't happen since we're passing an ErrorCollector in
		int line = re.lineNumber();
		// if (line>0) {
		Element elem = root.getElement(line);
		int offs = elem.getStartOffset();
		int len = elem.getEndOffset() - offs - 1;
		String msg = re.details();
		result.addNotice(new DefaultParserNotice(this, msg, line, offs, len));
		// }
	} catch (Exception e) {
		result.setError(e); // catch all
	}

	r.close();

	// Get any parser errors.
	switch (langSupport.getErrorParser()) {
		default:
		case RHINO:
			gatherParserErrorsRhino(errorHandler, root);
			break;
		case JSHINT:
			gatherParserErrorsJsHint(doc);
			break;
	}

	// addNotices(doc);
	support.firePropertyChange(PROPERTY_AST, null, astRoot);

	return result;

}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:59,代码来源:JavaScriptParser.java

示例5: execute

import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
public Object execute(Object[] args) {
    Context cx = RhinoUtil.enter();
    Object ret = null;
    try {
        Scriptable scope = RhinoUtil.getScope();
        Object jsRet;
        if (_elStyle && args != null) {
            Object host = getELStyleHost(cx, scope);
            jsRet = functionExecute(cx, scope, host, args);
        } else {
            jsRet = normalExecute(cx, scope);
        }
        ret = RhinoUtil.convertResult(cx, getExpectedClass(), jsRet);
    } catch (RhinoException e) {
        if (e instanceof WrappedException) {
            WrappedException we = (WrappedException) e;
            Throwable wrapped = we.getWrappedException();
            if (wrapped instanceof RenderingBrake) {
                RhinoUtil.removeWrappedException(we);
            }
        }

        // エラーとなったソース情報が微妙なので微調整。
        // 行番号はスクリプト次第でずれてしまう。
        int offsetLine;
        String message;
        String sourceName;
        if (e instanceof JavaScriptException
                && ((JavaScriptException)e).getValue() instanceof IdScriptableObject) {
            offsetLine = -1;
            IdScriptableObject scriptable =
                (IdScriptableObject) ((JavaScriptException) e).getValue();
            Object messageProperty = scriptable.get("message", scriptable);
            if (messageProperty != Scriptable.NOT_FOUND) {
                message = messageProperty.toString();
            } else {
                message = scriptable.toString();
            }
        } else {
            offsetLine = e.lineNumber() - _lineNumber + 1; // one "\n" is added
            message = e.details() + " in script=\n" + getText();
        }
        if (e.lineSource() == null && message != null) {
            String[] lines = message.split("\n");
            offsetLine = (lines.length > offsetLine) ? offsetLine : _offsetLine;
            if (offsetLine >= 0 && lines.length > offsetLine) {
                e.initLineSource(lines[offsetLine]);
                sourceName = _sourceName;
            } else {
                sourceName = e.sourceName();
            }
        } else {
            sourceName = e.sourceName();
        }
        throw new OffsetLineRhinoException(
                message,
                sourceName, e.lineNumber(), e.lineSource(),
                e.columnNumber(), offsetLine, e.getCause());
    } finally {
        Context.exit();
    }
    return ret;
}
 
开发者ID:seasarorg,项目名称:mayaa,代码行数:64,代码来源:TextCompiledScriptImpl.java


注:本文中的org.mozilla.javascript.RhinoException.details方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。