Spring 在AOP中从Mono抛出新的RuntimeException()

Spring 在AOP中从Mono抛出新的RuntimeException(),spring,error-handling,reactive,spring-webclient,spring-mono,Spring,Error Handling,Reactive,Spring Webclient,Spring Mono,我有一个反应式springboot应用程序,它是一个方面 @Before("approveRejectPointcut()") public void logAfterReturning(JoinPoint joinPoint) { Status newStatus = AspectUtils.returnFirstParameterOfTypeOrFail(allParameters, Status.class, "approveRejectPoi

我有一个反应式springboot应用程序,它是一个方面

@Before("approveRejectPointcut()")
public void logAfterReturning(JoinPoint joinPoint) {
   
    Status newStatus = AspectUtils.returnFirstParameterOfTypeOrFail(allParameters, Status.class, "approveRejectPointcut");
    String comments = AspectUtils.returnFirstParameterOfTypeOrFail(allParameters, String.class, "approveRejectPointcut");
    
    Mono<Object> someObjectOrException = someService.updateApplicationStatus(appId, newStatus, comments);
    
    someObjectOrException
      .subscribe(i->log.info(i),
            error->{
                log.info("we have some ex: "+error.getMessage());
                throw new RuntimeException("PLEASE LORD: "+error.getMessage()); 
      });
}
@Before(“approveRejectPointcut()”)
返回后的公共无效日志(JoinPoint JoinPoint){
Status newStatus=AspectUtils.returnFirstParameterOfTypeOrFail(所有参数,Status.class,“approveRejectPointcut”);
String comments=AspectUtils.returnFirstParameterOfTypeOrFail(allParameters,String.class,“approveRejectPointcut”);
Mono someObjectOrException=someService.updateApplicationStatus(appId、newStatus、comments);
someObjectOrException
.subscribe(i->log.info(i),
错误->{
log.info(“我们有一些例子:+error.getMessage());
抛出新的RuntimeException(“请注意:+error.getMessage());
});
}
这里发生的情况是,来自某个服务的updateApplicationStatus()在某个点抛出一个业务异常(这很好),在这方面,我打印了异常消息,这也很好。然而,当我试图抛出一个业务异常(在其基础上抛出一个RuntimeException)时。。但是,我可以在控制台中看到此异常。。它没有到达客户端。
我怀疑这是在另一个线程上抛出的。有什么线索吗?

最后,将外观改为@Around

@Around("approveRejectPointcut()")
public Mono<Object> logAfterReturning(ProceedingJoinPoint pjp) {
...
Mono<Object> someObjectOrException = someService.updateApplicationStatus(appId, newStatus, comments);
someObjectOrException
      .map(unused->pjp.proceed(pjp.getArgs())
      .onErrorMap(RuntimeException.class, (s)->{
            return new GenericBusinessException(s.getMessage());
      }); 
}
@Around(“approveRejectPointcut()”)
返回后的公共单声道日志(处理连接点pjp){
...
Mono someObjectOrException=someService.updateApplicationStatus(appId、newStatus、comments);
someObjectOrException
.map(未使用->pjp.procedue(pjp.getArgs())
.onErrorMap(RuntimeException.class)->{
返回新的GenericBusinessException(s.getMessage());
}); 
}
这样,如果服务中一切顺利->我们继续执行,否则,我们会抛出业务异常和来自服务的异常消息。也许该map()应该替换为接受函数的其他操作符:)