Catching context exceptions on injected AOP code RRS feed

  • Question

  • Hi everyone!


    I'm using AOP basic concepts to intercept my data access method calls so i can inject transactional control in them, just like TransactionScope. Everything's going just fine except by one thing: i start my transaction before method calling and complete its transaction just after its over (the method call). The problem is: if i get an exception in the middle of method calling i don't know how to make the after injection code get to know that an exception has been fired so i could stop it from completing my transaction.


    So, the question is: is there a way to know when an exception has been fired on my application without using try/catch statements?


    Thank you all!

    Thursday, May 24, 2007 4:59 PM


  • After a little brain work i found it. When you intercept activation phase and executes the original method you get a ReturnMessage object in return that contains a property called Exception.

    //Process the original Message
    IMessage n = next.SyncProcessMessage(message);

     if(n is ReturnMessage)
        hasException = null != ((ReturnMessage)n).Exception;

    Thank you
    Tuesday, May 29, 2007 12:35 PM