When checking Field-Level Security or object CRUD in Apex within a managed package, is it required to use conditional access to prevent the given operation (for the purposes of passing the security review), or would it also be acceptable to use an exception to to halt execution of the code?
The examples that I have encountered in the documentation use the former approach but does the latter approach introduce a vulnerability that would prevent the application from passing a security review?
Scenario 1: Using conditional logic:
if(Account.My_Custom_Field__c.getDescribe().isUpdateable(){
acct.My_Custom_Field = 'X';
update acct;
}
Scenario 2: Throwing an excpetion
if(!Account.My_Custom_Field__c.getDescribe().isUpdateable())
throw new MyCustomException('Example Message');
acct.My_Custom_Field = 'X';
update acct;