18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
try-catch: error.message?
Hi,
one of your examples for exception handling and logging is
If I am trying the following...
...sahi loggs
How do I access this "error" object?
Thanks,
Simon
one of your examples for exception handling and logging is
try{
_click(_link("does not exist"));
}catch(e){
_click(_link("linkByHtml")); // Corrective action
_logException(e); // Logs the exception, but does not fail
}
Is it possible to use the exception message which is being logged for own purposes? This would make the notifications sent out by Nagios more precise.If I am trying the following...
var $nagiosMessage="";
try {
_assertContainsText("ANMELDUNG", _heading2("I_AM_THE_WRONG_ELEMENT"),"Headline ANMELDUNG was not found!");
...
...
...
$nagiosMessage = "All tests passed ok.";
} catch(error) {
$nagiosMessage = error.message;
} finally {
if (ScriptRunner.hasErrors) {
sendResult2Nagios(2,$nagiosMessage);
} else {
sendResult2Nagios(0,$nagiosMessage);
}
}
...sahi loggs
JSERROR
_alert(error.message);
ReferenceError: error is not defined
How do I access this "error" object?
Thanks,
Simon
Comments
What you are doing is correct except that you should use $error instead of error.
Btw, if you did not have that _alert, even error would have worked.
Regards,
Narayan