shiro 自定义realm类 抛出自定义异常

本文介绍在使用Shiro自定义Realm时如何抛出并处理自定义异常。当自定义Realm中抛出异常,会被AuthenticationException捕获并包装。通过查看AuthenticationException源码,可以了解如何直接抛出自定义信息,或者创建自定义异常类继承自AuthenticationException来实现更精确的错误处理。
摘要由CSDN通过智能技术生成

在自定义realm抛出自定义异常时,会被Authenticationexception打包,

出现这样的异常

Authentication failed for token submission [xx.xx.xx.xx - xxx, rememberMe=false].  Possible unexpected error? (Typical or expected login exceptions should extend from AuthenticationException).

其实打开Authenticationexception,就会发现如下

/**
 * General exception thrown due to an error during the Authentication process.
 *
 * @since 0.1
 */
public class AuthenticationException extends ShiroException
{

    /**
     * Creates a new AuthenticationException.
     */
    public AuthenticationException() {
        super();
    }

    /**
     * Constructs a new AuthenticationException.
     *
     * @param message the reason for the exception
     */
    public AuthenticationException(String message) {
        super(message);
    }

    /**
     * Constructs a new AuthenticationException.
     *
     * @par
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值