Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9228669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:22:53+00:00 2026-06-18T05:22:53+00:00

I was trying out a demo on Exception handling in controller using an interception

  • 0

I was trying out a demo on Exception handling in controller using an interception @Finally.

I made an intentional NullPointerException in the controller and tried to catch the exception in the @Finally block.

When I tried this then it works:

@Finally
 static void log(Throwable e) {
   if( e == null ){
       Logger.info("Inside FInally: Action call was successful");
   } else{
       Logger.info("Inside Finally: Action call failed", e);
   }
 }

But if I try this the it does not work:

@Finally
static void log(NullPointerException e) {
   if( e == null ){
       Logger.info("Inside FInally: Action call was successful");
   } else{
       Logger.info("Inside Finally: Action call failed", e);
   }
 }

Again if I consider the @Catch interception then both the following works:

 @Catch(value = Throwable.class , priority = 2)
 public static void te(Throwable throwException){
    .....
 }

@Catch(value = NullPointerException.class , priority = 1)
public static void npe(Throwable throwNullPointerException){
    .....
 }

Why is the second scenario not working in @Finally interception? Is it a compulsion to use only Throwable superclass for any kind of exception rather than using any specific subclass exception?

Please let me know about this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:22:55+00:00Added an answer on June 18, 2026 at 5:22 am

    The online developer guide does not explicitly say that you cannot use specific Exception type. But considering the idea behind this @Finally intercetpion, I guess you are right; that is, @Finally only takes Throwable.

    Let’s think about it from this way, what if you have multiple catch statements in the method, only one catch will be triggered if there is an exception thrown. In this case, it would be confusing if the argument is NPE but the DBConnectionTimeout(for instance) is actually thrown. Therefore there is noway that your interceptor can work with other type of excpetion, nor you can have multiple @Finally interceptors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this famous airplay demo app: https://github.com/quellish/AirplayDemo/ and trying to figure out
I'm trying out the LoaderCursor example in the API Demo: package com.example.android.apis.app; import android.app.Activity;
I was planning on trying out Re-Fox: http://www.refox.net/ They have a demo version -
I'm trying out the horizontal bar RGraph demo with this code and it works
I came across this site ( http://demo.themezilla.com/memo/post-formats ) and I'm trying to figure out
Previously I have been trying to host multiple DEMO django projects using a virtual
This is a total n00b question. I am trying out using JQuery UI and
I was trying this demo out locally. If succeeded I should be able to
I'm trying out some dynamic web page background generation using lines and text. Take
I've been trying out a few lightboxes for my website using MooTools 1.4, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.