This new security method Security.stripInaccessible both strips out fields that the user has no rights to and will throw an exception if the object-level permissions are being violated.

What exception type is thrown (so I can catch and handle that specific type)?

1 Answer 1


It's a System.NoAccessException. The message is:

No access to entity: MyObject__c

Not sure the easiest way to verify, but I set up a Visualforce Page with the below controller so the running user didn't need appropriate permissions to execute anonymous Apex.

public with sharing class Demo
    public String type { get; private set; }
    public String message { get; private set; }
    public Demo()
            Security.stripInaccessible(AccessType.CREATABLE, new List<NoPerm__c> {
                new NoPerm__c()
        catch (Exception e)
            message = e.getMessage();
            type = e.getTypeName();

And the markup was simply:

<apex:page controller="Demo">
    <apex:pageMessage severity="FATAL"
                      detail="{!message}" />
  • Thanks, not in a position to test today and couldn't find it in the docs.
    – Keith C
    Feb 7, 2020 at 17:44
  • Yeah, dunno if it's in the docs.
    – Adrian Larson
    Feb 7, 2020 at 17:45
  • +1 Same thing that I did, you were just two minutes faster!
    – sfdcfox
    Feb 7, 2020 at 17:46
  • 1
    @sfdcfox I guess I've still got it!
    – Adrian Larson
    Feb 7, 2020 at 17:46
  • 4
    @KeithC The docs almost never tell you what exceptions can be thrown. It's one of the most annoying aspects of the docs.
    – sfdcfox
    Feb 7, 2020 at 17:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .