Results 1 to 5 of 5

Thread: Spring Exception Interceptor

Hybrid View

  1. #1

    Default 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. #2
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    Quote 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
    }

  3. #3

    Default

    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.)

  4. #4
    Join Date
    Jul 2008
    Location
    Columbus, OH
    Posts
    43

    Default

    Quote 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.
    Thanks,
    Frank Lamantia

  5. #5
    Join Date
    May 2008
    Location
    Central Florida, U.S.A.
    Posts
    36

    Default

    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.

Tags for this Thread

Posting Permissions

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