I have an apex class that does not interact with Aura. Sometimes I get the error "Can only throw this exception type from VisualForce or Aura context". I'm looking to see if I can catch that exception. I haven't been able to yet.
I've tried the following snippet but my code never gets the exception. Is there a way to catch it?
catch(System.LimitException l){
if(l.getMessage().contains('Can only throw this exception type from
VisualForce or Aura context')){
System.debug('System LimitException ' +l.getMessage());
}
}