Avoid Catch Block with just logs

Impact area

Manageability

Severity

Medium

Affected element

Apex Page

Rule ID

SF-JUST-LOG-CATCH

Impact

Catch blocks without code will cause exceptions to be caught without any action

Remediation

Explicitly handle any exceptions caught


Non compliant code:

} catch(System.CalloutException e) {
        System.debug('ERROR:' + e);
 }


Compliant code:

} catch(Exception ex){
      System.debug('ERROR:' + e);
      return '{"error": "' + ex.getMessage() + '"}';
}

Time to fix

30 min

What's here


Related content

Apex Page rules

Salesforce rules




Last modified on Jan 18, 2023