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 7572111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:50:34+00:00 2026-05-30T15:50:34+00:00

I am a C programmer and just learning some java recently because I am

  • 0

I am a C programmer and just learning some java recently because I am developing one android application. Currently I am in a situation. Following is the one.

public Class ClassA{

public ClassA();

public void MyMethod(){

   try{
   //Some code here which can throw exceptions
   }
   catch(ExceptionType1 Excp1){
   //Here I want to show one alert Dialog box for the exception occured for the user.
   //but I am not able to show dialog in this context. So I want to propagate it
   //to the caller of this method.
   }
   catch(ExceptionType2 Excp2){
   //Here I want to show one alert Dialog box for the exception occured for the user.
   //but I am not able to show dialog in this context. So I want to propagate it
   //to the  caller of this method.
   }
   }
}

Now I wan to use call the method MyMethod() somewhere else in another class. If some one can provide me some code snippet how to propagate the exceptions to the caller of MyMethod() so that I can display them in a dialog box in the caller method.

Sorry If I am not so much clear and weird in the way of asking this question.

  • 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-05-30T15:50:36+00:00Added an answer on May 30, 2026 at 3:50 pm

    Just don’t catch the exception in the first place, and change your method declaration so that it can propagate them:

    public void myMethod() throws ExceptionType1, ExceptionType2 {
        // Some code here which can throw exceptions
    }
    

    If you need to take some action and then propagate, you can rethrow it:

    public void myMethod() throws ExceptionType1, ExceptionType2 {
        try {
            // Some code here which can throw exceptions
        } catch (ExceptionType1 e) {
            log(e);
            throw e;
        }
    }
    

    Here ExceptionType2 isn’t caught at all – it’ll just propagate up automatically. ExceptionType1 is caught, logged, and then rethrown.

    It’s not a good idea to have catch blocks which just rethrow an exception – unless there’s some subtle reason (e.g. to prevent a more general catch block from handling it) you should normally just remove the catch block instead.

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

Sidebar

Related Questions

Hey everyone. I am an experienced java programmer and am just learning C++. Now
I'm a novice programmer with basic Java experience, and currently learning Python. I've stumbled
Possible Duplicate: Should I learn C before learning C++? As a professional (Java) programmer
I’m currently learning the Java Collections API and feel I have a good understanding
G'Day Programmers, I am from Java background however I have just started learning C++
I'm a flex programmer who has just started to learn android today, successfully starting
I need some specific and some general advice. I'm a fairly proficient Java programmer
I'm a young (highschool next year) beginner programmer, currently learning Python and starting to
I'm a C++ programmer just starting to learn Python. I'd like to know how
So I am a new programmer and I just installed XCode on my Macbook

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.