Which is better approach? : <p>I need to find subject, but it could be null. So have to do this without throwing exception. I have two approach and please suggest which is better?</p>

<pre><code>public static String getSafeSubject(SNSEvent.SNSRecord record){
        try{
            return record.getSNS().getSubject();
        }catch (Exception e){
            return "Failed to retrieve subject";
        }
}
</code></pre>

<pre><code>public static String getSafeSubject(SNSEvent.SNSRecord record){
  if(record == null || record.getSNS() == null || 
  record.getSNS().getSubject() == null){
            return "Failed to retrieve subject";
        }
        return record.getSNS().getSubject();
    }
</code></pre>
