So I am using HtmlUnit, and the method's signature looks like:
public HtmlAnchor getAnchorByText(String text)
throws ElementNotFoundException
So this means, the call to this method won't just return null, but it will throw an exception.
(I find this a pain!!, in c# methods usually just return a null if not found, way easier unless I am missing something??)
So I HAVE to wrap this call in an exception if I don't want my application to crash right?
How do I do this in Java?
reference: http://htmlunit.sourceforge.net/apidocs/index.html