mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 19:45:51 +01:00
improve exception handling of ThrowingEventBus
This commit is contained in:
@@ -30,10 +30,16 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.google.common.eventbus;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.event.EventBusException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -48,6 +54,14 @@ import java.lang.reflect.InvocationTargetException;
|
||||
public class ThrowingEventBus extends EventBus
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for ThrowingEventBus
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(ThrowingEventBus.class);
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@@ -64,8 +78,13 @@ public class ThrowingEventBus extends EventBus
|
||||
}
|
||||
catch (InvocationTargetException ex)
|
||||
{
|
||||
Throwable cause = ex.getCause();
|
||||
|
||||
Throwables.propagateIfPossible(cause);
|
||||
logger.trace("could not propagate exception, throw as EventBusException");
|
||||
|
||||
throw new EventBusException(
|
||||
"could not handle event ".concat(event.toString()), ex);
|
||||
"could not handle event ".concat(event.toString()), cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user