1
zhang
1 天以前 7d116115ade208f26ada36806642d2a3a6085c91
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.zy.common.config;
 
import com.zy.acs.common.domain.BaseResult;
import com.zy.acs.framework.exception.CoolException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.HandlerMethod;
 
/**
 * Created by vincent on 2019-06-09
 */
@RestControllerAdvice
public class CoolExceptionHandler {
 
    @ExceptionHandler(Exception.class)
    public BaseResult handlerException(HandlerMethod handler, Exception e) {
        e.printStackTrace();
        return BaseResult.error();
    }
 
    @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
    public BaseResult handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
        return BaseResult.error();
    }
 
    @ExceptionHandler(CoolException.class)
    public BaseResult handleRRException(Exception e) {
        return BaseResult.error(e.getMessage());
    }
 
}