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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:18:42+00:00 2026-05-23T12:18:42+00:00

Please note that I am not a java guru. I might not use the

  • 0

Please note that I am not a java guru. I might not use the right terminology, I learn java inside RFT on the fly. What is described below works exactly as stated.


In ruby we can code like

(code to execute) if (condition)

I want to do the same so my RFT (Rational Functional Tester) code is easy to read. I am going to call my custom functions in a way that looks like

        findANDclick(new String[]{"id", "menuButton"});
        findANDclick(new String[]{"src", ".*homeicon_calendar.*"}); 
        findANDclick(new String[]{"src", ".*cycle_templates.*"});   

But the whole RFT script needs to finish and don’t execute any other code in case of any of the findANDclick functions ‘failed’. The function searches for an object with in html page and if it doesn’t find any it throws new Exception via

throw new Exception("findANDclick: the object was not found");

so the instance of findANDclick ONLY throws an error so the next findANDclick is executed. But it makes no sense to continue as look for next object if the previous was not found and clicked on.

I was thinking that I can have a variable continue set to true and in case the exception is thrown the findANDclick will update it to false. Then I can do something like

    if (continue) { findANDclick(new String[]{"id", "menuButton"});}
    if (continue) { findANDclick(new String[]{"src", ".*homeicon_calendar.*"}); }   
    if (continue) { findANDclick(new String[]{"src", ".*cycle_templates.*"});   }

it would be great if I can do something like

        { findANDclick(new String[]{"id", "menuButton"}); } if (continue)
        { findANDclick(new String[]{"src", ".*homeicon_calendar.*"}); } if (continue)
        { findANDclick(new String[]{"src", ".*cycle_templates.*"}); } if (continue)
  • 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-23T12:18:42+00:00Added an answer on May 23, 2026 at 12:18 pm

    Radek! Try to execute the following example, just to clarify how the Java exception handling works.

    public class ExceptionHandling {
        /*Method that throws exception*/
        static void methodOne() throws Exception {
            System.out.println("methodOne();");
            try {
                throw new Exception();
            } catch (Exception e) {
                System.out.println("Exception caught in methodOne(), worked up, and thrown again.");
                throw new Exception();
            }
        }
    
        static void methodTwo() {
            System.out.println("methodTwo();");
        }
    
        public static void main(String[] args) {
            try {
                methodOne();
                methodTwo();
            } catch (Exception ex) {
                System.out.println("Exception caught in main()!");
            }
        }
    }
    

    Output of this example:

    methodOne();
    Exception caught in methodOne(), worked up, and thrown again.
    Exception caught in main()!
    

    It shows that the second method is never executed, if the first one throws an exception.

    P.S. This should be a comment. But it’s clearer in rich formatting.

    Solution suggested by Mathias Schwarz

    try { 
       findANDclick(new String[]{"id", "menuButton"});
       findANDclick(new String[]{"src", ".*homeicon_calendar.*"});    
       findANDclick(new String[]{"src", ".*cycle_templates.*"});   
    } catch (Exception e) {
       // Workup exception somehow.
    }
    

    has advantages to which you aspire (from Java developer’s point of view):

    1. It’s short;
    2. It’s clear for Java developer.

    Disadvantage is also clear: ugly exception handling construction.

    But in Java you can’t avoid it. It’s language rules.

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

Sidebar

Related Questions

Please note - I am not looking for the right way to open/read a
(please excuse that I didn't use aliases). I would like my query output to
Please note the Edit below for a lot more information, and a possible solution
Please note: In each step I describe below I'm logged in as the same
How do I print debug messages in the Google Chrome JavaScript Console? Please note
Please suggest some good resources to start writing Java Web services.
Please read the whole question. I'm not looking for an approach to managing multi-lingual
I usually store the Java applications and JAR files that I download from the
We run a website written in Java that uses JDBC with jTDS to access
I'm looking for a Java library that will give me access to raw Ethernet

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.