gpt4 book ai didi

java - 在@Around Aspect 中重新抛出异常

转载 作者:塔克拉玛干 更新时间:2023-11-01 23:08:08 25 4
gpt4 key购买 nike

<分区>

在一些操作之后,从周围方面向 rest Controller 中的 ExceptionHandler 重新抛出异常是否正常,如下所示:

@Around("execution(* *(..)) && @annotation(someAnnotation)")
public Object catchMethod(ProceedingJoinPoint point, SomeAnnotation someAnnotation) throws Throwable {
//some action
try {
result = point.proceed();
} catch (Exception e) {
//some action
throw e; //can I do this?
}
//some action
return result;
}

这是可行的,但我不知道是否出于某种原因我没有这样做。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com