All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tosan.client.http.starter.impl.feign.aspect.FeignUndeclaredThrowableExceptionAspect Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
package com.tosan.client.http.starter.impl.feign.aspect;

import com.tosan.client.http.starter.impl.feign.exception.FeignClientRequestExecuteException;
import feign.FeignException;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;

import java.lang.reflect.UndeclaredThrowableException;

/**
 * @author Ali Alimohammadi
 * @since 4/18/2021
 */
@Aspect
public class FeignUndeclaredThrowableExceptionAspect {

    @AfterThrowing(pointcut = "@within(com.tosan.client.http.starter.impl.feign.annotation.SdkController) ||" +
            " @annotation(com.tosan.client.http.starter.impl.feign.annotation.SdkController)",
            throwing = "exception")
    public void processCoreException(Exception exception) throws Throwable {
        if (exception instanceof UndeclaredThrowableException) {
            throw ((UndeclaredThrowableException) exception).getUndeclaredThrowable();
        } else if (exception instanceof FeignException) {
            throw new FeignClientRequestExecuteException(exception.getMessage(), exception);
        } else {
            throw exception;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy