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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:23:25+00:00 2026-06-11T09:23:25+00:00

I have some code that throws a potential error and I catch these, then

  • 0

I have some code that throws a potential error and I catch these, then jump into a finally block, here it is in ‘pseudo’ form.

private boolean myMethod(ResultSet rs1, ResultSet rs2){

Vector<String> temp = new Vector<String>();

try{

//add info into temp while condition is true
while(true){temp.add(information);}//potentially throws an SQL error

//test my temo object for some codition
if(false){throw InternalError();}


}catch (SQLException e){
     //send error message
}
catch (InternalError e){
     //send error message
}

finally{
//whatever happens I need to send a result of some sort!

if(temp.size() > 1){
   //create class member variable from this info
}

//send a message explaining that an error has occurred.

//this is the message to say if things have worked or not, so as the
//calling code can handle an re-run this method until this value returns true.
return booleanValue
}//end finally


}//end method

I’m not sure exactly what this error message means in this instance.

I generally handle any exceptions within any method that throws them, should I in this instance throw rather than handle the Exception, and catch both of the errors in a custom Exception?

The first 2 messages that I send out are mainly for development purposes, and because I have to handle them.
The message in my finally block will ultimately comprise the message to the user, asking them to confirm the situation, make a modification, abort or change how we got to this situation.

What should I do to ‘remove’ the compiler message. I don’t like to suppress warnings in my code as I don’t like the implication that I may suppress something else further down the chain, and also the suppression is for the whole method, I can’t add it in for just this small block of code.

Is there any advice for my situation.

Thanks in advance.

edit1: To reflect comments, sorry forgot to put the correct return type (silly mistake) same this the if(test){} closing brace.

PS. To those that have ‘downvoted’ you could put a comment and give me a chance to edit prior to downvoting. thanks. Also in my code these things aren’t giving me problems, its a case of ‘a quertyscript malfunction’ between brain and fingers during posting.

  • 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-11T09:23:26+00:00Added an answer on June 11, 2026 at 9:23 am

    Method return type is void and you have return statement return booleanValue in your finally block. I would use finally block to close non-java resource.

    If you want to return values then either return it in try block or catch block OR outside of try{} catch{} but not in finally{}.

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

Sidebar

Related Questions

I have error handling code that is designed to catch unnhandled exceptions, and then
I have some code that throws causes syncdb to throw an error (because it
I currently have some code that delibratly throws an exception if the user sends
We have some code that archives data from a Microsoft Access database into a
I have some code that throws an exception as follows. if (jobFinished) { ...
I have some java code that looks similar to this: private void startServer() throws
I have some code that gives a user id to a utility that then
I have some code that will change the background color of a specific label
I have some code that is supposed to return an NSString. Instead it is
I have some code that generates Visio masters for me, and some masters have

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.