package com.app.config.interceptor;
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.app.base.data.ApiResponseResult;
|
|
/**
|
* @author jinbin
|
* @date 2018-07-08 22:37
|
*/
|
@ControllerAdvice
|
public class GloablExceptionHandler {
|
@ResponseBody
|
@ExceptionHandler(Exception.class)
|
public Object handleException(Exception e) {
|
String msg = e.getMessage();
|
if (msg == null || msg.equals("")) {
|
msg = "服务器出错";
|
}
|
JSONObject jsonObject = new JSONObject();
|
jsonObject.put("message", msg);
|
//return jsonObject;
|
return ApiResponseResult.failure(msg);
|
}
|
}
|