Pass exceptions thrown in mod event buses back to FML to handle apropriately

This commit is contained in:
Matthew Prenger 2016-03-19 19:07:04 -05:00
parent ad03581fbe
commit ee6c041424
1 changed files with 12 additions and 2 deletions

View File

@ -44,6 +44,8 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.google.common.eventbus.SubscriberExceptionHandler;
import com.google.common.eventbus.SubscriberExceptionContext;
public class LoadController
{
@ -88,10 +90,18 @@ public class LoadController
{
Builder<String, EventBus> eventBus = ImmutableMap.builder();
for (ModContainer mod : loader.getModList())
for (final ModContainer mod : loader.getModList())
{
//Create mod logger, and make the EventBus logger a child of it.
EventBus bus = new EventBus(mod.getModId());
EventBus bus = new EventBus(new SubscriberExceptionHandler()
{
@Override
public void handleException(final Throwable exception, final SubscriberExceptionContext context)
{
LoadController.this.errorOccurred(mod, exception);
}
});
boolean isActive = mod.registerBus(bus, this);
if (isActive)
{