ScriptVM: Catch exceptions thrown from a JavaScriptCallback

These shouldn't crash the client
This commit is contained in:
Max Weber
2018-11-18 16:33:26 -07:00
parent b1dd15722d
commit b8ff7f8412

View File

@@ -118,8 +118,15 @@ public abstract class ScriptVMMixin implements RSClient
{ {
Object[] arguments = event.getArguments(); Object[] arguments = event.getArguments();
if (arguments != null && arguments.length > 0 && arguments[0] instanceof JavaScriptCallback) if (arguments != null && arguments.length > 0 && arguments[0] instanceof JavaScriptCallback)
{
try
{ {
((JavaScriptCallback) arguments[0]).run(event); ((JavaScriptCallback) arguments[0]).run(event);
}
catch (Exception e)
{
client.getLogger().error("Error in JavaScriptCallback", e);
}
return; return;
} }