自动化立体仓库 - WMS系统
vincent
2020-05-24 fb3b3aa7f0fcbfd3f3cb333b31a317f73605a9ec
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.core.common.R;
import com.core.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 R handlerException(HandlerMethod handler, Exception e) {
        e.printStackTrace();
        return R.error();
    }
 
    @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
    public R handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
        return R.error();
    }
 
    @ExceptionHandler(CoolException.class)
    public R handleRRException(CoolException e) {
        return R.parse(e.getMessage());
    }
 
}