If condition fails loop

I want to write an If statement that says:

If an image is not found then continue with the script
else if the image is found throw an error and halt the script

How would I write this?

if imageFound("someImage") then throw "Bad Image Showed Up!"


Thanks. Much simpler than I thought.