스크립트에서 예외가 발생할 때마다 Rhino는 이미 행 번호와 열 번호가있는 RhinoException을 발생시킵니다. 그러나 스크립트를 실행하면 Rhino에서 시작 줄 번호로 사용할 줄 번호를 제공해야합니다. 예외/오류가 발생한 실제 행 번호는이 번호와 관련됩니다. 그래서 뭔가 라인이 : 위의 코드에서
//-- Define a simple test script to test if things are working or not.
String testScript = "function simpleJavascriptFunction() {" +
" this line has syntax error." +
"}" +
"simpleJavascriptFunction();";
//-- Compile the test script.
Script compiledScript = Context.getCurrentContext().compileString(testScript, "My Test Script", 2, null);
//-- Execute the test script.
compiledScript.exec(Context.getCurrentContext(), anyJavascriptScope);
가 시작 줄 번호가 2로 설정 (compileString에 대한 호출의 세 번째 매개 변수()). 이 작업이 실행되면 Rhino는 lineNumber 속성이 '3'값으로 설정된 RhinoException을 throw합니다 (첫 번째 행은 두 번째 행으로 처리되고 두 번째 행은 b/c로 처리됩니다).
희망이 도움이됩니다.
사실 내가 생각하는 것은 불가능합니다. 실제로 스크립트를 호출하지는 않지만 Rhino는 내 객체에서 함수를 호출합니다. –