package com.persagy.adm.diagram.frame;

import com.persagy.adm.diagram.util.CallException;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * 统一异常拦截处理
 */
@Component
@Aspect
@Slf4j
public class ExceptionAspect {

    @Pointcut("execution(public * com.persagy.adm.diagram.controller.*Controller.*(..))")
    public void handle(){

    }

    @Around("handle()")
    public Object aroundInvoke(ProceedingJoinPoint point) throws Throwable {
        try{
            return point.proceed();
        } catch (CallException e) {
            return e.getErrorResult();
        }
    }

}