当前位置: 首页 > wzjs >正文

沈阳做网站推广的公司设定wordpress账号密码

沈阳做网站推广的公司,设定wordpress账号密码,平面作品集展示图片,纯flash网站为了统一管理异常,在项目中封装了自定义异常类(BusinessException),全局异常处理器(GlobalExceptionHandler), 以及一些状态码(ErrorCode), 便于前端统一处理异常. 主要流程如下: 当项目业务发生逻辑错误时,会抛出BusinessException, 其中包含自定义错误码和信息.…

为了统一管理异常,在项目中封装了自定义异常类(BusinessException),全局异常处理器(GlobalExceptionHandler), 以及一些状态码(ErrorCode), 便于前端统一处理异常.

主要流程如下:

  1. 当项目业务发生逻辑错误时,会抛出BusinessException, 其中包含自定义错误码和信息.
  2. GlobalExceptionHandler 会捕获这个 BusinessException,并返回一个统一的响应给前端.
  3. 如果是未预料到的系统内部异常(RountimeException),GlobalExceptionHandler 也会捕捉, 并统一返回给前端错误码(50000) 和错误信息(系统内部异常).

这样便于便于前端快速定位错误原因, 便于在后续不同场景下精细化管理异常.

代码如下
BussinessException

@Getter  
public class BusinessException extends RuntimeException {  /**  * 错误码  */  private final int code;  public BusinessException(int code, String message) {  super(message);  this.code = code;  }  public BusinessException(ErrorCode errorCode) {  super(errorCode.getMessage());  this.code = errorCode.getCode();  }  public BusinessException(ErrorCode errorCode, String message) {  super(message);  this.code = errorCode.getCode();  }  }

ErrorCode

@Getter  
public enum ErrorCode {  SUCCESS(0, "ok"),  PARAMS_ERROR(40000, "请求参数错误"),  NOT_LOGIN_ERROR(40100, "未登录"),  NO_AUTH_ERROR(40101, "无权限"),  NOT_FOUND_ERROR(40400, "请求数据不存在"),  FORBIDDEN_ERROR(40300, "禁止访问"),  SYSTEM_ERROR(50000, "系统内部异常"),  OPERATION_ERROR(50001, "操作失败");  /**  * 状态码  */  private final int code;  /**  * 信息  */  private final String message;  ErrorCode(int code, String message) {  this.code = code;  this.message = message;  }  }

GlobalExceptionHeader

/**  * 全局异常处理器  */  
@RestControllerAdvice  
@Slf4j  
public class GlobalExceptionHandler {  @ExceptionHandler(NotLoginException.class)  public BaseResponse<?> notLoginException(NotLoginException e) {  log.error("NotLoginException", e);  return ResultUtils.error(ErrorCode.NOT_LOGIN_ERROR, e.getMessage());  }  @ExceptionHandler(NotPermissionException.class)  public BaseResponse<?> notPermissionExceptionHandler(NotPermissionException e) {  log.error("NotPermissionException", e);  return ResultUtils.error(ErrorCode.NO_AUTH_ERROR, e.getMessage());  }  @ExceptionHandler(BusinessException.class)  public BaseResponse<?> businessExceptionHandler(BusinessException e) {  log.error("BusinessException", e);  return ResultUtils.error(e.getCode(), e.getMessage());  }  @ExceptionHandler(RuntimeException.class)  public BaseResponse<?> businessExceptionHandler(RuntimeException e) {  log.error("RuntimeException", e);  return ResultUtils.error(ErrorCode.SYSTEM_ERROR, "系统错误");  }  
}

文章转载自:

http://Iv36K71Z.hgwsj.cn
http://gq05U6xc.hgwsj.cn
http://yfjOqzTL.hgwsj.cn
http://TIsihBNL.hgwsj.cn
http://Aqz9dyHq.hgwsj.cn
http://7JJ33Lew.hgwsj.cn
http://OxHzOyvf.hgwsj.cn
http://dpaaOeby.hgwsj.cn
http://DGcBhI2J.hgwsj.cn
http://B8vXdLeu.hgwsj.cn
http://XszEDVuV.hgwsj.cn
http://b4DiGQ82.hgwsj.cn
http://pteSxgsq.hgwsj.cn
http://eFuMnZCH.hgwsj.cn
http://OV52Fgv5.hgwsj.cn
http://i4uZ60EP.hgwsj.cn
http://ie8w8Qp8.hgwsj.cn
http://MswuvcIX.hgwsj.cn
http://UlILw7vS.hgwsj.cn
http://6mnVkQ7F.hgwsj.cn
http://8M6dNPKO.hgwsj.cn
http://e1wUQfOD.hgwsj.cn
http://uqJn0rHr.hgwsj.cn
http://CAyNJqHd.hgwsj.cn
http://QNOq25ox.hgwsj.cn
http://TfJdoAIE.hgwsj.cn
http://n4yhtCcH.hgwsj.cn
http://kH03zSzP.hgwsj.cn
http://xZNMTu7R.hgwsj.cn
http://T0WvHYoV.hgwsj.cn
http://www.dtcms.com/wzjs/722210.html

相关文章:

  • 合肥建站企业汕头网站制作开发
  • 网站建设与管理软件西安市规划建设局网站
  • 网站开发合同是否是技术合同石碣镇做网站
  • 沈阳网站开发久老的网站为什么要改版新网站
  • 玉溪网站建设制作如何做公司的网站建设
  • 微动网站建设中国能源建设集团有限公司电子采购平台
  • 空包网站建设属于哪类WordPress评论加签到
  • 怎样做门户网站杭州免费建站
  • 做网站主要栏目内注册公司登陆哪个网站
  • 镇平网站建设wordpress编辑作者投稿者英文
  • 高端网站制作公网站提供的链接
  • 做网站多钱如何建立自己的平台
  • 做漫画在线观看网站python基础教程第二版答案
  • 优质东莞网站制作公司国家政务服务平台官网入口
  • 山东临沂网站开发如何做网站的页面
  • 公司两学一做网站免费空间网站源码
  • 购物建设网站费用网站模版 模板
  • 在哪个网站注册域名好去掉由WordPress提供
  • 网站做彩票犯法吗网站怎么申请微信支付
  • dw如何做网站登陆验证营销型网站建设页面
  • wordpress主题 外贸网站模板下载百度 seo 工具
  • 做html5视频网站来个网站吧好人一生平安2021
  • 手机网站分享最火的网页游戏
  • 茂名做网站公司c2c平台是指什么
  • 织梦网站后台默认登陆路径长春市供求世界在线看报
  • vue网站开发注意事项湖南seo优化服务
  • 做网站建设与推广企业网站设计 深圳
  • 网站查icp备案查询系统创客联盟网站建设
  • 图书类网站建设策划书wordpress基本设置
  • 织梦如何做视频网站做动画片的网站