18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

catching exceptions thrown from java

vinu32vinu32 Members
edited November -1 in Sahi - Open Source
Hi -
OS : Windows 7, 64 bits
Sahi : Version = V3.5, Build = 2011-07-19
Browser - IE8

I am using a ConfigReader java class inside my sahi script. When i pass a wrong properties file to the loadConfig() function in ConfigReader it throws an IOException.
When i call the same from sahi script how can i catch the exception and log it. Right now whatever properties file path is passed to the loadConfig() sahi says 'Success' .

This is my code ---
var $userdatadir = _userDataDir();
var $filepath = $userdatadir + "\\config\\applydirect3.properties";
try {
var e = new Packages.java.lang.Exception();
Packages.com.fadv.sahi.ConfigReader.loadConfig($filepath);
}catch(e){
_alert("exception occured " + e);
}

thanks
Vinod

Comments

  • Hi Vinod,

    Using java script try catch you will not be able to catch the Exception thrown from java.

    You can use the try catch method directly in loadConfig method in java.

    Regards
    Sumitra
  • Hi Sumitra -

    Thanks for your reply. I am having a try-catch around my java function but will not know from SAHI if that function fails.

    Anyways i will deal with this. Please close the post.

    thanks
    Vinod
This discussion has been closed.