package org.springblade.common.utils;

import com.yeepay.yop.sdk.exception.YopServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @author July
 * @version 1.0.0
 * @ClassName GlobalExceptionHandler.java
 * @Description 全局异常处理类
 * @createTime 2021年10月08日 15:06:00
 */
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

	@ExceptionHandler(YopServiceException.class)
	public R defaultErrorHandler(YopServiceException e) {
		return R.fail(e.getStatusCode(), e.getErrorMessage() + "：" + e.getSubMessage());
	}
}
