本文整理汇总了Java中org.mozilla.javascript.RhinoException.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java RhinoException.getCause方法的具体用法?Java RhinoException.getCause怎么用?Java RhinoException.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.RhinoException
的用法示例。
在下文中一共展示了RhinoException.getCause方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callHiringProcessCompany
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
void callHiringProcessCompany(Company company, ApplicationProfiles ap) {
if (hiringProcess != null) {
try {
ThreadLocal.setCompany(company);
long time = System.nanoTime();
hiringProcess.run(ap);
company.getGame().getResult().getCreateNotExists(company.getName())
.addRunTime("hiringProcess", System.nanoTime() - time);
} catch (RhinoException e) {
if (!(e.getCause() instanceof GameException)) {
String formattedStackTrace = ExceptionConverter.convertToString(e);
company.getGame().getResult().addError(formattedStackTrace);
log.error("Failed to call the company.hiringProcess handler. Player " + company.getName()
+ " bankrupt", e);
company.setBankruptFromError(formattedStackTrace);
}
}
}
ThreadLocal.resetCompany();
}
示例2: callLaunch
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
void callLaunch() {
try {
if (launch != null) {
ThreadLocal.setCompany(this);
long time = System.nanoTime();
launch.run();
game.getResult().getCreateNotExists(getName()).addRunTime("launch", System.nanoTime() - time);
}
} catch (RhinoException e) {
if (!(e.getCause() instanceof GameException)) {
String formattedStackTrace = ExceptionConverter.convertToString(e);
game.getResult().addError(formattedStackTrace);
log.error("Failed to call the company.launch handler. Player " + name + " bankrupt", e);
setBankruptFromError(formattedStackTrace);
}
}
}
示例3: callWeekly
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
void callWeekly() {
try {
if (doWeekly != null) {
ThreadLocal.setCompany(this);
long time = System.nanoTime();
doWeekly.run();
game.getResult().getCreateNotExists(getName()).addRunTime("weekly", System.nanoTime() - time);
}
} catch (RhinoException e) {
if (!(e.getCause() instanceof GameException)) {
String formattedStackTrace = ExceptionConverter.convertToString(e);
game.getResult().addError(formattedStackTrace);
log.error("Failed to call the company.launch handler. Player " + name + " bankrupt", e);
setBankruptFromError(formattedStackTrace);
}
}
ThreadLocal.resetCompany();
}
示例4: callDaily
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
void callDaily() {
try {
if (doDaily != null) {
ThreadLocal.setCompany(this);
long time = System.nanoTime();
doDaily.run(game.getDailyStatisticsManager().getLastDay(this));
game.getResult().getCreateNotExists(getName()).addRunTime("daily", System.nanoTime() - time);
}
} catch (RhinoException e) {
if (!(e.getCause() instanceof GameException)) {
String formattedStackTrace = ExceptionConverter.convertToString(e);
game.getResult().addError(formattedStackTrace);
log.error("Failed to call the company.launch handler. Player " + name + " bankrupt", e);
setBankruptFromError(formattedStackTrace);
}
}
ThreadLocal.resetCompany();
}
示例5: callMonthly
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
void callMonthly() {
try {
if (doMonthly != null) {
ThreadLocal.setCompany(this);
long time = System.nanoTime();
doMonthly.run();
game.getResult().getCreateNotExists(getName()).addRunTime("monthly", System.nanoTime() - time);
}
} catch (RhinoException e) {
if (!(e.getCause() instanceof GameException)) {
String formattedStackTrace = ExceptionConverter.convertToString(e);
game.getResult().addError(formattedStackTrace);
log.error("Failed to call the company.doMonthly handler. Player " + name + " bankrupt", e);
setBankruptFromError(formattedStackTrace);
}
}
ThreadLocal.resetCompany();
}
示例6: callRealEstateAgent
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
void callRealEstateAgent(RealEstateProfiles ap) {
if (realEstateAgent != null) {
try {
ThreadLocal.setCompany(this);
long time = System.nanoTime();
realEstateAgent.run(ap);
game.getResult().getCreateNotExists(getName()).addRunTime("realEstateAgent", System.nanoTime() - time);
} catch (RhinoException e) {
if (!(e.getCause() instanceof GameException)) {
String formattedStackTrace = ExceptionConverter.convertToString(e);
game.getResult().addError(formattedStackTrace);
log.error("Failed to call the company.realEstateAgent handler. Player " + name + " bankrupt", e);
setBankruptFromError(formattedStackTrace);
}
}
}
ThreadLocal.resetCompany();
}
示例7: callFoodDelivery
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
void callFoodDelivery(FoodDelivery fd) {
log.debug("Food delivery for {} = {}", name, fd);
try {
if (foodDelivery != null) {
ThreadLocal.setCompany(this);
long time = System.nanoTime();
foodDelivery.run(fd);
game.getResult().getCreateNotExists(getName()).addRunTime("foodDelivery", System.nanoTime() - time);
}
} catch (RhinoException e) {
if (!(e.getCause() instanceof GameException)) {
String formattedStackTrace = ExceptionConverter.convertToString(e);
game.getResult().addError(formattedStackTrace);
log.error("Failed to call the company.launch handler. Player " + name + " bankrupt", e);
setBankruptFromError(formattedStackTrace);
}
}
ThreadLocal.resetCompany();
}
示例8: readScripts
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
private void readScripts(List<User> userList) {
ContextFactory contextFactory = ContextFactory.getGlobal();
Context context = contextFactory.enterContext();
try {
for (User user : userList) {
Company company = new Company(this, user.getUsername(), grocer);
ThreadLocal.setCompany(company);
ScriptableObject prototype = context.initStandardObjects();
prototype.setParentScope(null);
Scriptable scope = context.newObject(prototype);
scope.setPrototype(prototype);
Object jsCompany = new SandboxNativeJavaObject(scope, company, Company.class);
prototype.put("company", scope, jsCompany);
Object jsSystemout = new SandboxNativeJavaObject(scope,
new DebugAdapter(this, gameRun.getResult(), company.getName()), DebugAdapter.class);
prototype.put("out", scope, jsSystemout);
prototype.put("console", scope, jsSystemout);
try {
long time = System.nanoTime();
context.evaluateString(scope, user.getMainJavaScript(), company.getName(), 1, null);
getResult().getCreateNotExists(company.getName()).addRunTime("init", System.nanoTime() - time);
getResult().getCreateNotExists(company.getName()).setCode(user.getMainJavaScript());
} catch (RhinoException e) {
if (e.getCause() instanceof GameException) {
log.info("Failed to initialize the JavaScript, but found a GameException", e);
} else {
String formattedStackTrace = ExceptionConverter.convertToString(e);
gameRun.getResult().addError(formattedStackTrace);
log.error("Failed to initialize the JavaScript. Player " + company.getName() + " bankrupt", e);
company.setBankruptFromError(formattedStackTrace);
}
}
companies.add(company);
}
ThreadLocal.resetCompany();
} finally {
Context.exit();
}
}
示例9: 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;
}