try{ if (!checkSms(eCouponBusinessSubmitRequest.getMobile(),eCouponBusinessSubmitRequest.getSmsCode())) { throw new BusinessException(BadResponseEnum.CHECK_CODE_ERROR); } Message<ECouponBusinessSubmit> message = eCouponBusinessService.businessSubmit(property, eCouponBusinessSubmitRequest); handleReult(message, resultModel, t -> { return t.getBiz(); }); return resultModel; } catch (Exception e) { resultModel.setSuccess(false); resultModel.setErrorCode("2"); resultModel.setErrorMsg("请求失败,请稍后再试"); return resultModel; 如果验证码错误返回的结果是什么 }

时间: 2024-04-05 21:33:53 浏览: 11
如果验证码错误,将会抛出 BusinessException 异常,并且异常信息为 CHECK_CODE_ERROR,然后进入 catch 代码块中,此时 resultModel 对象的 success 属性会被设置为 false,errorCode 属性会被设置为 "2",errorMsg 属性会被设置为 "请求失败,请稍后再试",最终返回 resultModel 对象作为结果。所以,如果验证码错误,返回的结果将会是一个 success 属性为 false,errorCode 属性为 "2",errorMsg 属性为 "请求失败,请稍后再试" 的 resultModel 对象。
相关问题

try{ if (!checkSms(eCouponBusinessSubmitRequest.getMobile(),eCouponBusinessSubmitRequest.getSmsCode())) { throw new BusinessException(BadResponseEnum.CHECK_CODE_ERROR); }消息<ECouponBusinessSubmit> message = eCouponBusinessService.businessSubmit(property, eCouponBusinessSubmitRequest);handleReult(message, resultModel, t -> { return t.getBiz(); });返回结果模型;} catch (Exception e) { resultModel.setSuccess(false); resultModel.setErrorCode(“2”); resultModel.setErrorMsg(“请求失败,请稍后再试”); return resultModel; 如果验证码错误想返回验证码错误的信息如何实现

如果想要返回验证码错误的信息,可以在 catch 代码块中捕获 BusinessException 异常,并根据异常信息设置 resultModel 对象的 errorMsg 属性,然后将 resultModel 对象作为结果返回即可。修改后的代码如下: ``` try { if (!checkSms(eCouponBusinessSubmitRequest.getMobile(), eCouponBusinessSubmitRequest.getSmsCode())) { throw new BusinessException(BadResponseEnum.CHECK_CODE_ERROR); } Message<ECouponBusinessSubmit> message = eCouponBusinessService.businessSubmit(property, eCouponBusinessSubmitRequest); handleReult(message, resultModel, t -> { return t.getBiz(); }); return resultModel; } catch (BusinessException e) { // 捕获 BusinessException 异常 resultModel.setSuccess(false); resultModel.setErrorCode("1"); // 可以将 errorCode 设置为一个特定的错误码,表示验证码错误 resultModel.setErrorMsg("验证码错误,请重新输入"); // 设置 errorMsg 属性为验证码错误的提示信息 return resultModel; } catch (Exception e) { resultModel.setSuccess(false); resultModel.setErrorCode("2"); resultModel.setErrorMsg("请求失败,请稍后再试"); return resultModel; } ``` 在上述代码中,我们添加了一个 catch 代码块来捕获 BusinessException 异常,然后根据需要设置 resultModel 对象的 errorMsg 属性,表示验证码错误的信息。如果抛出其他异常,仍然按照之前的方式处理并返回结果。

orderDO.setOrderStatusCode(OrderStatusEnum.WAIT_ISSUED.getCode()) if(!orderDO.getOrderStatusCode().equals(OrderStatusEnum.SAVED.getCode()) | !orderDO.getOrderStatusCode().equals(OrderStatusEnum.WAIT_APPOINTMENT.getCode()) | !orderDO.getOrderStatusCode().equals(OrderStatusEnum.WAIT_ISSUED.getCode()) | !orderDO.getOrderStatusCode().equals(OrderStatusEnum.INTERCEPTED.getCode())){ throw new BusinessException("该订单状态无法作废"); }

这段Java代码的意思是,如果订单的状态不是已保存、待预约、待发货或被拦截状态之一,那么就将其状态设置为待发货,并继续执行后续代码。如果订单的状态是上述四个状态之一,那么就会抛出一个自定义的业务异常,提示该订单状态无法作废。其中,OrderStatusEnum是一个枚举类型,它定义了不同的订单状态码。BusinessException是一个自定义的异常类,用于表示业务异常情况。

相关推荐

try { if (StringUtils.isBlank(AccessTokenInfoRequestDTO.getAccessToken())) { throw new BusinessException(ResponseCodeEnum.ACCESSTOKEN_ILLEGAL.getCode(), ResponseCodeEnum.ACCESSTOKEN_ILLEGAL.getMessage()); } else { TokenInfoDTO tokenInfoDTO = this.getTokenInfo(AccessTokenInfoRequestDTO.getAccessToken()); String accountId = tokenInfoDTO.getUserId(); String deviceToken = tokenInfoDTO.getDeviceToken(); String accToken = RedisCacheUtil.getStringForPrefix(accountId, new RedisTokenKeyEnum[]{RedisTokenKeyEnum.APP_USER_ACCOUNT}); if (StringUtils.isEmpty(accToken)) { throw new BusinessException(ResponseCodeEnum.ACCESS_TOKEN_LOSE.getCode(), ResponseCodeEnum.ACCESS_TOKEN_LOSE.getMessage()); } else if (!AccessTokenInfoRequestDTO.getAccessToken().equals(accToken)) { throw new BusinessException(ResponseCodeEnum.ACCESS_TOKEN_COVER.getCode(), ResponseCodeEnum.ACCESS_TOKEN_COVER.getMessage()); } else if (!ContextUtils.getAppRequestHeaderDTO().getDeviceToken().equals(deviceToken)) { throw new BusinessException(ResponseCodeEnum.ACCESS_TOKEN_COVER.getCode(), ResponseCodeEnum.ACCESS_TOKEN_COVER.getMessage()); } } } catch (BusinessException businessException) { LogUtil.boErrorLog("校验用户token失败:" + businessException.getMessage()); verifyAccessTokenResponseDTO = VerifyAccessTokenResponseDTO.builder().verifyFlag(false).errorDescription(businessException.getMessage()).build(); } catch (Exception exception) { LogUtil.boErrorLog("校验用户token异常:" + exception.getMessage()); verifyAccessTokenResponseDTO = VerifyAccessTokenResponseDTO.builder().verifyFlag(false).errorDescription(ResponseCodeEnum.ACCESSTOKEN_ILLEGAL.getMessage()).build(); }是啥意思

优化一下代码并给出详细代码 // 判断该用户是否是自研用户 if (!OverseaUtils.isOversea(clientId)) { throw new BusinessException(180000, "非自研用户,无法使用基金提取至银行卡"); } // 判断币种信息 if ("0".equals(request.getCurrency())) { throw new BusinessException(180001, "人民币无法使用该功能"); } DepositBalanceResponse depositBalanceResponse = new DepositBalanceResponse(); WithdrawalsFundReq withdrawalsFundReq = new WithdrawalsFundReq(); InComeReq inComeReq = new InComeReq(); inComeReq.setIncomeCurrency(request.getCurrency()); List<OwnBankCardVo> allOwnBankCards = bankCardManagerAppService.getAllOwnBankCards(clientId, null, RequestUtil.getClientIp(), inComeReq); if (allOwnBankCards.size() > 0) { boolean verifyBankWithdrawFunds = verifyBankWithdrawFundsRepository.verifyBankWithdrawFunds(clientId, allOwnBankCards.get(0).getNumber(), deviceId); if (!verifyBankWithdrawFunds) { throw new BusinessException(180021, "根据监管要求,请使用单笔入金达到10000港币(或等值其他货币)的银行卡进行出金操作"); } if (allOwnBankCards.get(0).isBoundTrans() && allOwnBankCards.get(0).getOutcomeStatus().contains(request.getCurrency())) { withdrawalsFundReq.withdrawalMode = "4"; depositBalanceResponse.setManner("0"); } else { withdrawalsFundReq.withdrawalMode = "6"; depositBalanceResponse.setManner("1"); } } else { throw new BusinessException(180003, "请输入正确的eid"); } withdrawalsFundReq.bankEid = request.getEid(); withdrawalsFundReq.balance = request.getBalance(); withdrawalsFundReq.stockCode = request.getStockCode(); withdrawalsFundReq.clientId = clientId; BaseResponse<WithdrawalsFundDTO> withdrawalsFundDTOBaseResponse = tradeFundHandler.withdrawalsFund(withdrawalsFundReq); if (withdrawalsFundDTOBaseResponse != null) { if (withdrawalsFundDTOBaseResponse.getStatus() == 0 && withdrawalsFundDTOBaseResponse.getData() != null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); depositBalanceResponse.setClientId(clientId); depositBalanceResponse.setCommitTime(simpleDateFormat.format(new Date())); depositBalanceResponse.setEid(withdrawalsFundDTOBaseResponse.getData().eid); } if (withdrawalsFundDTOBaseResponse.getStatus() != 0) { if (-2302004 == withdrawalsFundDTOBaseResponse.getStatus()) { throw new BusinessException(OutComeEnum.BANKING_SECURITIES_BUSINESS_IS_NOT_ALLOWED.getId(), OutComeEnum.BANKING_SECURITIES_BUSINESS_IS_NOT_ALLOWED.getName()); } throw new BusinessException(withdrawalsFundDTOBaseResponse.getStatus(), withdrawalsFundDTOBaseResponse.getMessage(), false); } } return depositBalanceResponse;

@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception { String method = request.getMethod(); String requestURI = request.getRequestURI(); if (o instanceof ResourceHttpRequestHandler || o instanceof ParameterizableViewController) { return true; } String accessName = "无"; HandlerMethod handlerMethod = (HandlerMethod) o; ApiOperation methodAnnotation = handlerMethod.getMethodAnnotation(ApiOperation.class); if (Validator.valid(methodAnnotation)) { accessName = methodAnnotation.value(); log.warn("########## requestURI: {} , method: {} , HandlerMethod: {} , IP: {} ##########", requestURI, method, accessName, IPUtil.getIPAddress(request)); } else { log.error("########## requestURI: {} , HandlerMethod: {} , IP: {} ##########", requestURI, method, IPUtil.getIPAddress(request)); } for (String url : passUrl) { if (UrlUtils.isLike(requestURI, url)) { return !method.equals("OPTIONS"); } } boolean hasPerm = false; if (!method.equals("OPTIONS")) { try { String token = request.getHeader("token"); System.out.println("token -------->>>>>> " + token); if (!Validator.valid(token)) { throw new BusinessException(CommonErrorCode.TOKEN_REMIND, "token不能为空"); } token = (String) permRedisManager.get(token); if (!Validator.valid(token)) { throw new BusinessException(CommonErrorCode.TOKEN_REMIND, "请重新登录"); } Map<String, Claim> result = JWTBuilder.parseJWT(token); if (Validator.valid(result.get(AuthUtil.SYS_EMPLOYEE_NAME))) { // hasPerm = true; DepositBox depositBox = setAttribute(request, result, AuthUtil.SYS_EMPLOYEE_NAME, token); //操作记录 String finalAccessName = accessName; } else if ((Validator.valid(result.get(AuthUtil.MEMBER_NAME)))) { if (requestURI.startsWith("/bg")) { throw new BusinessException(CommonErrorCode.NO_SESSION); } hasPerm = true; setAttribute(request, result, AuthUtil.MEMBER_NAME, token); } } catch (BusinessException e) { throw e; } catch (Exception e) { if (e instanceof NullPointerException) { throw new BusinessException(CommonE rrorCode.TOKEN_REMIND, "token无效"); } else if (e instanceof JWTDecodeException) { throw new BusinessException(CommonErrorCode.TOKEN_REMIND, "token信息不完整"); } else { throw new BusinessException(e.toString()); } } } if (!method.equals("OPTIONS") && !hasPerm) { throw new BusinessException(CommonErrorCode.NO_SESSION); } return !method.equals("OPTIONS"); }解释代码

最新推荐

recommend-type

C++中try throw catch异常处理的用法示例

主要给大家介绍了关于C++中try throw catch异常处理的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者使用C++具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
recommend-type

C++编程异常处理中try和throw以及catch语句的用法

主要介绍了C++编程异常处理中try和throw以及catch语句的用法,包括对Catch块的计算方式的介绍,需要的朋友可以参考下
recommend-type

####这是一篇对python的详细解析

python
recommend-type

菜日常菜日常菜日常菜日常

菜日常菜日常菜日常菜日常
recommend-type

VB学生档案管理系统设计(源代码+论文).rar

计算机专业毕业设计VB精品论文资源
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

用Spring boot和vue写一个登录注册界面

好的,这是一个比较常见的技术问题,我可以为您提供一些参考资料和思路。首先,您可以使用Spring Boot作为后端框架来处理用户认证和注册的逻辑,比如使用Spring Security实现用户登录认证。同时,您还需要设计相应的数据模型和数据库表结构来存储用户信息。在前端方面,您可以使用Vue.js作为框架来构建登录注册页面,使用Axios来发起API请求并和后端进行交互。当然,在实现过程中,还需要考虑一些具体细节,比如数据校验、安全性和用户体验等方面。希望这些信息能够帮助到您。
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。