package com.hwrj.cloud.portal.config.exception;

import com.hwrj.cloud.common.api.CommonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常捕获
 * @author 大仙
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 处理自定义异常
     * @param ex
     * @return
     */
    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public CommonResult handleOrderException(RuntimeException ex) {
        ex.printStackTrace();
        return CommonResult.failed(500 ,ex.getMessage());
    }
}