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

  • Spring Exception Interceptor

    Hi,

    We have implemented a SPRING interceptor, which is invoked for exception raised in application. Is there any way to suppress that exception in interceptor itself, so that the process will continue as it is and it wont result in termination.

  • #2
    Originally posted by yogeshcjadhav View Post
    Hi,

    We have implemented a SPRING interceptor, which is invoked for exception raised in application. Is there any way to suppress that exception in interceptor itself, so that the process will continue as it is and it wont result in termination.
    Of course you can. Just use the following error-prone approach:

    Code:
    try {
        // business logic
    } catch (Throwable e) {
        // ignore and have problems later
    }

    Comment


    • #3
      Hi,

      Thanks for replying, but in that case the service class will endup having those try/catch blocks. At the end of the day, the application will have two approaches one in which an app uses interceptor while in some scenario there is try/catch block. (which basically we dont want inside the code.)

      Comment


      • #4
        Originally posted by yogeshcjadhav View Post
        Hi,

        Thanks for replying, but in that case the service class will endup having those try/catch blocks. At the end of the day, the application will have two approaches one in which an app uses interceptor while in some scenario there is try/catch block. (which basically we dont want inside the code.)
        I think you mis-understood what Denis was saying. The logic to 'catch' that exception should be in the interceptor itself.

        Comment


        • #5
          What do you mean by "allow the process to continue"? If you are talking about the controller continuing, then that isn't possible unless you catch the exception and handle it appropriately in the method that throws the exception.

          However, if you mean continuing by hitting the other methods in the interceptor then you probably want to modify the HandlerAdapter to catch the error.

          If you are talking about handling the exception in a more elegant way, then you may want to look at a HandlerExceptionResolver.

          In any case, something has to catch the error. Otherwise it will go all the way through to the container to handle.

          Comment

          Working...
          X