Be more specific when catching exceptions when determining if an element is present