Java 类com.google.common.eventbus.SubscriberExceptionContext 实例源码

项目:CustomWorldGen    文件:LoadController.java   
public LoadController(Loader loader)
{
    this.loader = loader;
    this.masterChannel = new EventBus(new SubscriberExceptionHandler()
    {
        @Override
        public void handleException(Throwable exception, SubscriberExceptionContext context)
        {
            FMLLog.log("FMLMainChannel", Level.ERROR, exception, "Could not dispatch event: %s to %s", context.getEvent(), context.getSubscriberMethod());
        }
    });
    this.masterChannel.register(this);

    state = LoaderState.NOINIT;
    packageOwners = ArrayListMultimap.create();

}
项目:PortlandStateJava    文件:UnhandledExceptionEventTest.java   
@Test
public void unhandledExceptionInEventThreadCallsSubscriberExceptionHandler() {
  SubscriberExceptionHandler handler = mock(SubscriberExceptionHandler.class);
  EventBus bus = new EventBus(handler);

  final IllegalStateException exception = new IllegalStateException("Excepted Unhandled Exception");
  bus.register(new Object() {
    @Subscribe
    public void throwUnhandledException(TriggerUnhandledException event) {
      throw exception;
    }
  });

  bus.post(new TriggerUnhandledException());

  verify(handler).handleException(eq(exception), any(SubscriberExceptionContext.class));
}
项目:ProjectAres    文件:EventExceptionHandler.java   
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
    loggers.get(context.getSubscriber().getClass()).log(
        Level.SEVERE,
        "Exception dispatching " + context.getEvent().getClass().getName() +
        " to " + context.getSubscriber().getClass().getName() +
        "#" + context.getSubscriberMethod().getName(),
        exception
    );
}
项目:Biliomi    文件:EventSubscriberExceptionHandler.java   
@Override
public void handleException(Throwable throwable, SubscriberExceptionContext subscriberExceptionContext) {
  String eventName = subscriberExceptionContext.getEvent().getClass().getSimpleName();
  Class<?> subscriber = subscriberExceptionContext.getSubscriber().getClass();

  LogManager.getLogger(subscriber).error("An error occurred on event " + eventName + " in " + subscriber.getName(), throwable);
}
项目:CustomWorldGen    文件:LoadController.java   
@Subscribe
public void buildModList(FMLLoadEvent event)
{
    Builder<String, EventBus> eventBus = ImmutableMap.builder();

    for (final ModContainer mod : loader.getModList())
    {
        //Create mod logger, and make the EventBus logger a child of it.
        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)
        {
            activeModList.add(mod);
            modStates.put(mod.getModId(), ModState.UNLOADED);
            eventBus.put(mod.getModId(), bus);
            FMLCommonHandler.instance().addModToResourcePack(mod);
        }
        else
        {
            FMLLog.log(mod.getModId(), Level.WARN, "Mod %s has been disabled through configuration", mod.getModId());
            modStates.put(mod.getModId(), ModState.UNLOADED);
            modStates.put(mod.getModId(), ModState.DISABLED);
        }
        modNames.put(mod.getModId(), mod.getName());
    }

    eventChannels = eventBus.build();
}
项目:mentor    文件:MentorEventBus.java   
MentorEventBus() {
    this(Executors.newWorkStealingPool(), new SubscriberExceptionHandler() {
        @Override
        public void handleException(Throwable exception, SubscriberExceptionContext context) {
            Log.error("Error in event handler ({})", context, exception);
        }
    });
}
项目:space-travels-3    文件:GuavaSubscriberExceptionHandler.java   
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context)
{
    String message = "Event: "
        + context.getEvent()
        + "\r\nSubscriber: "
        + context.getSubscriber()
        + "\r\nSubscriber method:"
        + context.getSubscriberMethod();
    ErrorHandlerProvider.handle(context.getEventBus().toString(), message, exception);
}
项目:pheno4j    文件:ManagedEventBus.java   
@Override
public void handleException(final Throwable e, final SubscriberExceptionContext context) {
    if ((e instanceof ClassCastException) && e.getMessage().contains(PoisonPill.class.getName())) {
        LOG.debug("Poision Pill processed on: {}", context.getSubscriber().getClass().getSimpleName());
    } else {
        String msg = String.format("Could not call %s/%s on bus %s", context.getSubscriber().getClass().getSimpleName(),
                context.getSubscriberMethod().getName(), name);
        LOG.error(msg, e);
    }
}
项目:metasfresh    文件:EventBus.java   
@Override
public void handleException(final Throwable exception, final SubscriberExceptionContext context)
{
    String errmsg = "Could not dispatch event: " + context.getSubscriber() + " to " + context.getSubscriberMethod()
            + "\n Event: " + context.getEvent()
            + "\n Bus: " + context.getEventBus();
    logger.error(errmsg, exception);
}
项目:GRIP    文件:GripCoreModule.java   
protected void onSubscriberException(Throwable exception, @Nullable SubscriberExceptionContext
    exceptionContext) {
  if (exception instanceof InterruptedException) {
    logger.log(Level.FINE, "EventBus Subscriber threw InterruptedException", exception);
    Thread.currentThread().interrupt();
  } else {
    logger.log(Level.SEVERE, "An event subscriber threw an exception", exception);
    eventBus.post(new UnexpectedThrowableEvent(exception, "An event subscriber threw an "
        + "exception on thread '" + Thread.currentThread().getName() + "'"));
  }
}
项目:sfera    文件:Bus.java   
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
    Class<?> listenerClass = context.getSubscriber().getClass();
    String method = context.getSubscriberMethod().getName();
    String event = context.getEvent().getClass().getSimpleName();

    Logger logger = LoggerFactory.getLogger(listenerClass);
    logger.error("Error dispatching event '" + event + "' to '"
            + listenerClass.getSimpleName() + "." + method + "'", exception);
}
项目:PortlandStateJava    文件:EventBusThatPublishesUnhandledExceptionEvents.java   
public EventBusThatPublishesUnhandledExceptionEvents() {
  super(new SubscriberExceptionHandler() {
    @Override
    public void handleException(Throwable throwable, SubscriberExceptionContext subscriberExceptionContext) {
      postUncaughtExceptionEvent(throwable);
    }
  });

  errorMessageBus.register(this);
}
项目:tellets    文件:AuxiliaryProcess.java   
@Subscribe
public void handleException(ExceptionEvent e)
{
    if (log.isErrorEnabled())
    {
        final String format = "当前事件为: %s\n当前订阅者为: %s\n订阅方法为: %s\nEventBus为: %s\n";
        String msg = "\n";
        log.error("检测到异常 :", e.getException());

        msg += "===================================\n";
        msg += "异常详细信息:\n";

        SubscriberExceptionContext ctx = e.getContext();
        if (ctx != null)
        {
            msg += String.format(format, ctx.getEvent(), ctx.getSubscriber(), ctx.getSubscriberMethod(), ctx
                    .getEventBus());
        } else
            msg += "无上下文信息.\n";

        if (e.getExtra() != null)
        {
            msg += String.format("附加信息为: %s \n", e.getExtra());
        } else
            msg += "无附加信息.\n";

        msg += "===================================";
        log.error(msg);
    }
}
项目:tellets    文件:Events.java   
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context)
{
    if (context.getEvent() instanceof ExceptionEvent)
    {
        log.error("处理错误过程中发生错误 上下文:" + context, exception);
        return;
    }
    ExceptionEvent event = new ExceptionEvent(exception, context);
    bus.post(event);
}
项目:AppBaseForVaadin    文件:AppEventBus.java   
public AppEventBus() {
  eventbus = new EventBus(new SubscriberExceptionHandler() {
    @Override
    public void handleException(Throwable exception, SubscriberExceptionContext context) {
      log.error("Could not dispatch event: " + context.getSubscriber() + " to " + context.getSubscriberMethod());
      exception.printStackTrace();
    }
  });
}
项目:minebox    文件:GlobalErrorHandler.java   
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
    handleError("error in thread '" + Thread.currentThread().getName()
            + "' dispatching event to " + context.getSubscriber().getClass() + "." + context.getSubscriberMethod().getName(), exception);
}
项目:quorrabot    文件:ExceptionHandler.java   
@Override
public void handleException(Throwable thrwbl, SubscriberExceptionContext sec) {
    com.gmt2001.Console.err.println("Failed to dispatch event " + sec.getEvent().toString() + " to " + sec.getSubscriberMethod().toString());
    com.gmt2001.Console.err.printStackTrace(thrwbl);
}
项目:tools    文件:GlobalErrorHandler.java   
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
    handleError("error in thread '" + Thread.currentThread().getName()
            + "' dispatching event to " + context.getSubscriber().getClass() + "." + context.getSubscriberMethod().getName(), exception);
}
项目:incubator-tamaya-sandbox    文件:EventBus.java   
@Override
public void handleException(Throwable throwable, SubscriberExceptionContext subscriberExceptionContext) {
    throwable.printStackTrace();
}
项目:imotSpot    文件:DashboardEventBus.java   
@Override
public final void handleException(final Throwable exception,
        final SubscriberExceptionContext context) {
    exception.printStackTrace();
}
项目:vaadin-vertx-samples    文件:DashboardEventBus.java   
@Override
public final void handleException(final Throwable exception,
        final SubscriberExceptionContext context) {
    exception.printStackTrace();
}
项目:runelite    文件:RuneLiteModule.java   
private static void eventExceptionHandler(Throwable exception, SubscriberExceptionContext context)
{
    log.warn("uncaught exception in event subscriber", exception);
}
项目:nexus-public    文件:Slf4jSubscriberExceptionHandler.java   
@Override
public void handleException(final Throwable exception, final SubscriberExceptionContext context) {
  logger.error("Could not dispatch event {} to subscriber {} method [{}]",
      context.getEvent(), context.getSubscriber(), context.getSubscriberMethod(), exception);
}
项目:PhantomBot    文件:ExceptionHandler.java   
@Override
public void handleException(Throwable thrwbl, SubscriberExceptionContext sec)
{
    com.gmt2001.Console.err.println("Failed to dispatch event " + sec.getEvent().toString() + " to " + sec.getSubscriberMethod().toString());
    com.gmt2001.Console.err.printStackTrace(thrwbl);
}
项目:GRIP    文件:GripCoreTestModule.java   
@Override
protected void onSubscriberException(Throwable exception, SubscriberExceptionContext
    exceptionContext) {
  // Do not call super, we don't want the default functionality
  subscriberExceptions.add(new SubscriberThrowablePair(exception, exceptionContext));
}
项目:GRIP    文件:GripCoreTestModule.java   
private SubscriberThrowablePair(Throwable exception, SubscriberExceptionContext
    exceptionContext) {
  this.exception = checkNotNull(exception, "Throwable cannot be null");
  this.exceptionContext = checkNotNull(exceptionContext, "SubscriberExceptionContext cannot "
      + "be null");
}
项目:play-hysterix    文件:HysterixContext.java   
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
    logger.error("Hysterix EventBus exception", exception);
}
项目:jesos    文件:ManagedEventBus.java   
@Override
public void handleException(final Throwable e, final SubscriberExceptionContext context)
{
    LOG.error(e, "Could not call %s/%s on bus %s", context.getSubscriber().getClass().getSimpleName(), context.getSubscriberMethod().getName(), name);
}
项目:OpenRTS    文件:RethrowingExceptionHandler.java   
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
    throw new TechnicalException(exception);
}
项目:bazel    文件:BlazeRuntime.java   
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
  logger.log(Level.SEVERE, "Failure in EventBus subscriber", exception);
  LoggingUtil.logToRemote(Level.SEVERE, "Failure in EventBus subscriber.", exception);
}
项目:bazel    文件:BlazeRuntime.java   
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
  BugReport.handleCrash(exception);
}
项目:vis-editor    文件:EventBusExceptionEvent.java   
public EventBusExceptionEvent (Throwable exception, SubscriberExceptionContext context) {
    this.exception = exception;
    this.context = context;
}
项目:tellets    文件:ExceptionEvent.java   
public ExceptionEvent(Throwable exception, SubscriberExceptionContext context)
{
    this(exception, context, null);
}
项目:tellets    文件:ExceptionEvent.java   
public ExceptionEvent(Throwable exception, SubscriberExceptionContext context, Object extra)
{
    this.exception = exception;
    this.context = context;
    this.extra = extra;
}