Results 1 to 5 of 5

Thread: AOP and Exception Handling

  1. #1
    Join Date
    Jul 2007
    Posts
    12

    Default 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. #2
    Join Date
    Aug 2006
    Posts
    382

    Default Spring has support for trapping exceptions

    See http://static.springframework.org/sp...-advice-throws.

    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?
    Greg L. Turnquist (@gregturn), SpringSource/VMware
    Project Lead: Spring Python and author of Spring Python 1.1 and Python Testing Cookbook.
    Listen to Pond Jumpers, the international podcast for open source developers.
    These comments are my own personal opinions, and do not reflect those of my company.

  3. #3
    Join Date
    Jul 2007
    Posts
    12

    Default

    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. #4
    Join Date
    Aug 2006
    Posts
    382

    Default 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.
    Greg L. Turnquist (@gregturn), SpringSource/VMware
    Project Lead: Spring Python and author of Spring Python 1.1 and Python Testing Cookbook.
    Listen to Pond Jumpers, the international podcast for open source developers.
    These comments are my own personal opinions, and do not reflect those of my company.

  5. #5
    Join Date
    Mar 2005
    Posts
    135

    Default

    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.

Posting Permissions

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