| | |
| | | package com.whyc.exception; |
| | | |
| | | import com.whyc.constant.UserOperation; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.RestControllerAdvice; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | |
| | | /**错误捕捉,状态码:202*/ |
| | | @ExceptionHandler(Exception.class) |
| | | @ResponseStatus(HttpStatus.ACCEPTED) |
| | | public Response sendErrorResponse2Defined(Exception e, HttpServletResponse response){ |
| | | return new Response().setII(0,"接口请求异常,请联系软件人员进行处理.异常信息"+e.toString()); |
| | | public Response sendErrorResponse2Defined(Exception e, HttpServletResponse response, HttpServletRequest request){ |
| | | String exceptionStr = e.toString(); |
| | | //单项提取-登录超时 |
| | | if(exceptionStr.contains("login") && exceptionStr.contains("imeout")){ |
| | | CommonUtil.record(ActionUtil.getUser().getUId(), UserOperation.TYPE_LOGIN_TIMEOUT.getType(),"登录请求超时","异常信息:"+ exceptionStr); |
| | | }else { |
| | | CommonUtil.record(ActionUtil.getUser().getUId(), UserOperation.TYPE_EXCEPTION.getType(), "接口请求异常", "异常信息:" + exceptionStr); |
| | | } |
| | | return new Response().setII(0,"接口请求异常,请联系软件人员进行处理.异常信息"+ exceptionStr); |
| | | } |
| | | |
| | | |