Top Rounds
| We are Hiring! |

Exception Handling in Sahi ·

Exceptions are handled via regular javascript try catch blocks since Sahi V2.

Syntax

try{ // sahi statements }catch(e){ // Corrective action // Can print exact source of error in log // Can throw the same or another exception }

Eg.

Corrective Action

try{ _click(_link("does not exist")); }catch(e){ _log("Exception occured"); // simple logging. no failure _click(_link("linkByHtml")); // Corrective action }

Corrective Action and Log the Exception Message

try{ _click(_link("does not exist")); }catch(e){ _click(_link("linkByHtml")); // Corrective action _logException(e); // Logs the exception, but does not fail }

Corrective Action, Log and then Fail

try{ _click(_link("does not exist")); }catch(e){ _click(_link("linkByHtml")); // Corrective action _logExceptionAsFailure(e); // Logs the exception, and fails, // and in the logs, points to the original line as source of failure. }




---


Top Rounds