Results 1 to 2 of 2

Thread: How can I intercept a exception just when it occurred?

  1. #1
    Join Date
    Nov 2012
    Posts
    18

    Question How can I intercept a exception just when it occurred?

    Some code like this:
    Code:
    public class A {
    
      @Autoware
      private B b;  
    
      public void a() {
        //AAA: some logic process that maybe throw exception
        b.b();
      }
    
    }
    
    public class B {
      
      public void b() {
        //BBB: some logic process maybe also throw exception
      }
      
    }
    Both exceptions in A.a() and B.b() need to be intercept, so i use @AfterThrowing annotation do it. but the question is, when i call A.a() in other code and exception has occurred in B.b(), the Advice will execute twice! because exception that occurred in B.b() was propagating to its caller A.a().

    I can't swallow the exception silently, because i use spring-amqp, above codes is on Consumer side, i need some message processing that based on the exceptions that occurred in Consumer.

    So, How can i intercept a exception just when it occurred? ignore propagation of it.


    Any reply is greatly appreciated.


  2. #2
    Join Date
    Nov 2012
    Posts
    18

    Default

    Anyone help me? will be appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •