Helius
2021-06-23 b8ca59259b0690f664ee70ecca69dfb53700c653
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
package com.xzx.gc.common.utils;
 
import com.xzx.gc.common.exception.BusinessException;
import com.xzx.gc.common.exception.PlatformException;
import com.xzx.gc.common.exception.RestException;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
 
@Slf4j
@UtilityClass
public class ExceptionUtils {
 
    public void err(Integer code,String msg,Exception e){
        error(code,msg,e);
 
    }
 
    public void err(String msg,Exception e){
        error(-1,msg,e);
    }
 
    private void error(Integer code,String msg,Exception e){
        if(e instanceof RestException||e instanceof BusinessException){
            throw  new BusinessException(code,msg,msg);
        }else {
            throw  new PlatformException(msg,e);
        }
    }
 
}