判断是否是唯一索引异常

if(e instanceof SQLIntegrityConstraintViolationException) {
                //RunTimeException异常抛出了事务会回滚
                throw new BaseRuntimeException("用户不能多重角色,如果需要请联系管理员!");
            }  else {
                throw new BaseRuntimeException("服务器异常,请联系管理员");
            }

 

posted @ 2020-12-17 17:34  动力起点  阅读(534)  评论(0编辑  收藏  举报