Need help to overwrite or log user defied exception.

In the following code I want to log error when the image is not found.
Can I throw an user defined exception or overwrite exception when the image is not found.
BeginTestCase JobSubmissionException
try 
	
	Set the SearchRectangle to (1620,0,1920,123)
	WaitFor 4,  "Notifications/Nft_JobSucess_Icon"  
	
	--throws (name:"name" , reason:"reason")
	
catch anException
	Log "**************************************************************************"
	LogError "Job Submission Failed"
	Log "**************************************************************************"
	
	
end try

EndTestCase JobSubmissionException


Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    You can use the "throw" command to throw an exception, but you'd want to do it in the catch block. eggPlant is going to throw and exception anyway if the image isn't found, and you can't override that. A more common way of dealing with this scenario is:
    if not imageFound(4,"Notifications/Nft_JobSucess_Icon") then
    logError "Job Submission Failed"
    end if
    
    If you throw an exception here, the script will end. Executing a LogError command causes the script to be logged as having failed, but allows the execution to continue.
Sign In or Register to comment.