Announcement Announcement Module
No announcement yet.
AOP and Exception Handling Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP and Exception Handling

    does spring has built in aspects for exception handling? if so,
    is there any documentation about exception handling with Spring AOP?

  • #2
    Spring has support for trapping exceptions


    If you are talking about pre-built aspects, then I don't think so. What do you want to do when you get an exception? Log it?


    • #3
      In my methods I don't want repeat the same catch statements.
      for example DataAccessException.
      I want to log the exception, create a new exception with a custom message and rethrow it.


      • #4
        Doesn't sound like an AOP solution

        AOP Is great at applying the same solution to lots of different places based on rules. If every instance has custom code, i.e. a different solution, AOP doesn't fit the bill in my book.


        • #5
          You could define a pointcut that will be applied after throwing a certain exception. Even with a simple around advice, you could handle the exception in a proper way.

          But why would you like to rethrow it?
          If it is an unrecoverable exception, it is not likely that you can do anything with the new exception.