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.

does 'throw' works in sahi?

AmarAmar Members
edited November -1 in Sahi - Open Source
try {
throw "DIALOG DOES NOT EXIST";
}
catch (e) {
var $err = e;
_logException($err);
}

i am getting this error when i executed above code.

JSERROR
Cannot convert NaN to java.lang.Integer at Jan 27, 2010 5:11:12 PM

1. is it possible to log the custom exception using _logException($err);
2. is it possible stop the script after this exception.

Thanks in advance.
arjun

Comments

  • Hi arjun,

    There was some bug in sahi.

    1. Yes, it is possible to log the custom exception using _logException function
    In the upcoming release, you can expect permanent fix for this bug.

    For time being, modify _logException function in lib.js located at <sahi base directory>/htdocs/spr directory as,
             Sahi.prototype._logException = function(e){
                   if (e instanceof SahiException)
                         ScriptRunner.logException(e.message, e.debugInfo, false);
                   else if(typeof e == "string")
                         ScriptRunner.logException(e, null, false);    
                   else
                         ScriptRunner.logExceptionWithLineNumber(e.message, e.lineNumber-1, false);
            };
    

    and restart sahi.

    2. Yes, it is possible to stop the script after this exception.

    Try it as,
         try {
            throw "DIALOG DOES NOT EXIST";
            // Remaining part of the script should be 
            // included here inside the try catch block. 
            // so that it stops the execution once the exception is thrown.
        } 
        catch (e) {
           var $err = e;      
          _logException($err);
        }
    

    Thanks,
    Venky
  • AmarAmar Members
    Hi Venky

    Thank you very much.

    regards,
    arjun
This discussion has been closed.