package com.lantone.exception;

import com.diagbot.exception.CommonException;
import com.lantone.common.api.CommonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description: mdsp全局异常处理
 * @author: rengb
 * @time: 2021/1/5 18:27
 */
@ControllerAdvice
public class MdspExceptionHandler {

    @ResponseBody
    @ExceptionHandler(value = CommonException.class)
    public CommonResult handleValidException(CommonException e) {
        if (e.getErrorCode() != null) {
            return CommonResult.failed(e.getMessage());
        }
        return CommonResult.failed(e.getMessage());
    }

}