Java Code Examples for org.apache.bsf.BSFException#REASON_UNKNOWN_LANGUAGE
The following examples show how to use
org.apache.bsf.BSFException#REASON_UNKNOWN_LANGUAGE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeanShellBSFEngine.java From beanshell with Apache License 2.0 | 5 votes |
public Object eval ( String source, int lineNo, int columnNo, Object expr) throws BSFException { if ( ! (expr instanceof String) ) throw new BSFException("BeanShell expression must be a string"); try { return interpreter.eval( ((String)expr) ); } catch ( InterpreterError e ) { throw new BSFException(BSFException.REASON_UNKNOWN_LANGUAGE, "BeanShell interpreter internal error: "+e + sourceInfo(source,lineNo,columnNo), e); } catch ( TargetError e2 ) { throw new BSFException(BSFException.REASON_EXECUTION_ERROR, "The application script threw an exception: " + e2.getTarget() + sourceInfo(source,lineNo,columnNo), e2); } catch ( EvalError e3 ) { throw new BSFException(BSFException.REASON_OTHER_ERROR, "BeanShell script error: "+e3 + sourceInfo(source,lineNo,columnNo), e3); } }
Example 2
Source File: BeanShellBSFEngine.java From beanshell with Apache License 2.0 | 4 votes |
/** This is an implementation of the BSF apply() method. It exectutes the funcBody text in an "anonymous" method call with arguments. */ /* Note: the apply() method may be supported directly in BeanShell in an upcoming release and would not require special support here. */ public Object apply ( String source, int lineNo, int columnNo, Object funcBody, Vector namesVec, Vector argsVec ) throws BSFException { if ( namesVec.size() != argsVec.size() ) throw new BSFException("number of params/names mismatch"); if ( !(funcBody instanceof String) ) throw new BSFException("apply: functino body must be a string"); String [] names = new String [ namesVec.size() ]; namesVec.copyInto(names); Object [] args = new Object [ argsVec.size() ]; argsVec.copyInto(args); try { if ( !installedApplyMethod ) { interpreter.eval( bsfApplyMethod ); installedApplyMethod = true; } bsh.This global = (bsh.This)interpreter.get("global"); Object value = global.invokeMethod( "_bsfApply", new Object [] { names, args, (String)funcBody } ); return Primitive.unwrap( value ); } catch ( InterpreterError e ) { throw new BSFException(BSFException.REASON_UNKNOWN_LANGUAGE, "BeanShell interpreter internal error: "+e + sourceInfo(source,lineNo,columnNo), e); } catch ( TargetError e2 ) { throw new BSFException(BSFException.REASON_EXECUTION_ERROR, "The application script threw an exception: " + e2.getTarget() + sourceInfo(source,lineNo,columnNo), e2); } catch ( EvalError e3 ) { throw new BSFException(BSFException.REASON_OTHER_ERROR, "BeanShell script error: "+e3 + sourceInfo(source,lineNo,columnNo), e3); } }