当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionUtils.indexOfThrowable方法代码示例

本文整理汇总了Java中org.apache.commons.lang.exception.ExceptionUtils.indexOfThrowable方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtils.indexOfThrowable方法的具体用法?Java ExceptionUtils.indexOfThrowable怎么用?Java ExceptionUtils.indexOfThrowable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.exception.ExceptionUtils的用法示例。


在下文中一共展示了ExceptionUtils.indexOfThrowable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleOnTimerException

import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
protected void handleOnTimerException(RuntimeException e) {
    int reIdx = ExceptionUtils.indexOfType(e, RemoteException.class);
    if (reIdx > -1) {
        RemoteException re = (RemoteException) ExceptionUtils.getThrowableList(e).get(reIdx);
        for (RemoteException.Cause cause : re.getCauses()) {
            //noinspection ThrowableResultOfMethodCallIgnored
            if (cause.getThrowable() instanceof NoUserSessionException) {
                log.warn("NoUserSessionException in timer {}, timer will be stopped", getLoggingTimerId());
                stop();
                break;
            }
        }
    } else if (ExceptionUtils.indexOfThrowable(e, NoUserSessionException.class) > -1) {
        log.warn("NoUserSessionException in timer {}, timer will be stopped", getLoggingTimerId());
        stop();
    }

    throw e;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:CubaTimer.java

示例2: handleTimerException

import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
protected void handleTimerException(RuntimeException ex) {
    if (ExceptionUtils.indexOfType(ex, java.net.ConnectException.class) > -1) {
        // If a ConnectException occurred, just log it and ignore
        log.warn("onTimer error: " + ex.getMessage());
    } else {
        // Otherwise throw the exception, but first search for NoUserSessionException in chain,
        // if found - stop the timer
        int reIdx = ExceptionUtils.indexOfType(ex, RemoteException.class);
        if (reIdx > -1) {
            RemoteException re = (RemoteException) ExceptionUtils.getThrowableList(ex).get(reIdx);
            for (RemoteException.Cause cause : re.getCauses()) {
                //noinspection ThrowableResultOfMethodCallIgnored
                if (cause.getThrowable() instanceof NoUserSessionException) {
                    log.warn("NoUserSessionException in timer, timer will be stopped");
                    disposeTimer();
                    break;
                }
            }
        } else if (ExceptionUtils.indexOfThrowable(ex, NoUserSessionException.class) > -1) {
            log.warn("NoUserSessionException in timer, timer will be stopped");
            disposeTimer();
        }

        throw ex;
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:DesktopTimer.java

示例3: onAuthenticationFailure

import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public void onAuthenticationFailure( HttpServletRequest request, HttpServletResponse response, AuthenticationException exception ) throws IOException, ServletException
{
    final String username = request.getParameter( "j_username" );

    request.getSession().setAttribute( "username", username );

    securityService.registerFailedLogin( username );

    I18n i18n = i18nManager.getI18n();

    if ( ExceptionUtils.indexOfThrowable( exception, LockedException.class )  != -1)
    {
        request.getSession().setAttribute( "LOGIN_FAILED_MESSAGE", i18n.getString( "authentication.message.account.locked" ) );
    }
    else
    {
        request.getSession().setAttribute( "LOGIN_FAILED_MESSAGE", i18n.getString( "authentication.message.account.invalid" ) );
    }


    super.onAuthenticationFailure( request, response, exception );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:24,代码来源:CustomExceptionMappingAuthenticationFailureHandler.java

示例4: toStatus

import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
 * Returns the payment status that corresponds to the given error
 */
public PaymentStatus toStatus(final Throwable error) {
    if (error instanceof InvalidCredentialsException) {
        return PaymentStatus.INVALID_CREDENTIALS;
    } else if (error instanceof BlockedCredentialsException) {
        return PaymentStatus.BLOCKED_CREDENTIALS;
    } else if (error instanceof InvalidUserForChannelException) {
        return PaymentStatus.INVALID_CHANNEL;
    } else if (error instanceof NotEnoughCreditsException) {
        return PaymentStatus.NOT_ENOUGH_CREDITS;
    } else if (error instanceof UpperCreditLimitReachedException) {
        return PaymentStatus.RECEIVER_UPPER_CREDIT_LIMIT_REACHED;
    } else if (error instanceof MaxAmountPerDayExceededException) {
        return PaymentStatus.MAX_DAILY_AMOUNT_EXCEEDED;
    } else if (error instanceof IllegalArgumentException || error instanceof ValidationException || error instanceof UnexpectedEntityException || error instanceof EntityNotFoundException || error instanceof UserNotFoundException) {
        return PaymentStatus.INVALID_PARAMETERS;
    } else if (ExceptionUtils.indexOfThrowable(error, DataIntegrityViolationException.class) != -1) {
        return PaymentStatus.INVALID_PARAMETERS;
    } else {
        return PaymentStatus.UNKNOWN_ERROR;
    }
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:25,代码来源:PaymentHelper.java


注:本文中的org.apache.commons.lang.exception.ExceptionUtils.indexOfThrowable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。