本文整理汇总了Java中org.springframework.util.ErrorHandler.handleError方法的典型用法代码示例。如果您正苦于以下问题:Java ErrorHandler.handleError方法的具体用法?Java ErrorHandler.handleError怎么用?Java ErrorHandler.handleError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler.handleError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeListener
import org.springframework.util.ErrorHandler; //导入方法依赖的package包/类
/**
* Invoke the given listener with the given event.
* @param listener the ApplicationListener to invoke
* @param event the current event to propagate
* @since 4.1
*/
@SuppressWarnings({"unchecked", "rawtypes"})
protected void invokeListener(ApplicationListener listener, ApplicationEvent event) {
ErrorHandler errorHandler = getErrorHandler();
if (errorHandler != null) {
try {
listener.onApplicationEvent(event);
}
catch (Throwable err) {
errorHandler.handleError(err);
}
}
else {
listener.onApplicationEvent(event);
}
}
示例2: invokeListener
import org.springframework.util.ErrorHandler; //导入方法依赖的package包/类
/**
* Invoke the given listener with the given event.
* @param listener the ApplicationListener to invoke
* @param event the current event to propagate
* @since 4.1
*/
@SuppressWarnings({"unchecked", "rawtypes"})
protected void invokeListener(ApplicationListener listener, ApplicationEvent event) {
ErrorHandler errorHandler = getErrorHandler();
if (errorHandler != null) {
try {
listener.onApplicationEvent(event);
}
catch (Throwable err) {
errorHandler.handleError(err);
}
}
else {
try {
listener.onApplicationEvent(event);
}
catch (ClassCastException ex) {
// Possibly a lambda-defined listener which we could not resolve the generic event type for
LogFactory.getLog(getClass()).debug("Non-matching event type for listener: " + listener, ex);
}
}
}
示例3: invokeErrorHandler
import org.springframework.util.ErrorHandler; //导入方法依赖的package包/类
/**
* Invoke the registered ErrorHandler, if any. Log at warn level otherwise.
* @param ex the uncaught error that arose during JMS processing.
* @see #setErrorHandler
*/
protected void invokeErrorHandler(Throwable ex) {
ErrorHandler errorHandler = getErrorHandler();
if (errorHandler != null) {
errorHandler.handleError(ex);
}
else {
logger.warn("Execution of JMS message listener failed, and no ErrorHandler has been set.", ex);
}
}