Announcement Announcement Module
Collapse
No announcement yet.
Spring Async UncaughtExceptionHandler Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Async UncaughtExceptionHandler

    Code:
    @Async
    public void asyncExceptionTest() {
        int i=1/0;
    }
    How can I log this using Spring Async framework without having to put try catch around every async method? It doesnt seem to pass to the DefaultUncaughtExceptionHandler like normal.

  • #2
    Hello


    Consider use AOP (around advice)

    Let me know your advance

    Comment


    • #3
      Thanks for your reply...AOP seems like a solution but I think it would be better if you could directly specify the error handler. Would be more elegant IMO.

      Comment


      • #4
        AOP offer a special type of advice. After advice, it is executed if an exception was thrown or not, even
        you can work with specific types of exceptions like parameters, read documentation for more details.

        To be honest I think AOP is the best option

        Comment


        • #5
          Thanks for your response but I think using AOP is a bit heavyweight and it would be much clearer, transparent and explicit if you could define your own ErrorHandler. There is something available for the @Scheduled to allow you to specify the error handler not sure why not for the @Async?

          Comment

          Working...
          X