|
|
@@ -1,30 +0,0 @@ |
|
|
|
package com.telpo.iotgateway.exception; |
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler; |
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice; |
|
|
|
import response.ERRORCODE; |
|
|
|
import response.Result; |
|
|
|
|
|
|
|
import java.text.MessageFormat; |
|
|
|
|
|
|
|
/** |
|
|
|
* @program: DataPushServer |
|
|
|
* @description: 全局异常拦截 |
|
|
|
* @author: linwl |
|
|
|
* @create: 2020-07-11 10:29 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@RestControllerAdvice(basePackages = "com.telpo.datapushserver.controller") |
|
|
|
public class GobalExceptionHandler { |
|
|
|
@ExceptionHandler(value = Exception.class) |
|
|
|
@ResponseBody |
|
|
|
public Result<Boolean> exceptionErrorHandler(Exception e) throws Exception { |
|
|
|
log.error(MessageFormat.format("推送服务发生异常:{0}!", e.getMessage()), e); |
|
|
|
return new Result.Builder<Boolean>() |
|
|
|
.setCode(ERRORCODE.SystemErr) |
|
|
|
.setMessage(MessageFormat.format("系统发生异常:{0}!", e.getMessage())) |
|
|
|
.build(); |
|
|
|
} |
|
|
|
} |