[SalesForce] SObject row does not allow errors in Salesforce before trigger

I wrote this logic inside a before insert/update trigger to apply a validation logic. But I am getting error saying – SObject row does not allow errors. Althought the text inside addError is appearing in the debug log but its not showing up in the call object as desired from the code.
Below is the code. Kindly assist on how to avoid the error.

 trigger Call_Sample_Limit_Check on Call2_Sample__c (before insert, before update) {  
 if (Trigger.new != null) {
  Map<Call2_c,Integer> callErrorMap = new Map<Call2__c,Integer>();
  callErrorMap=Call_Sample_Limit.callSample(Trigger.new);
  Set<Call2__c> callErrorSet= callErrorMap.keySet();
    if(callErrorMap.size()>0){
      for(Call2__c c:callErrorSet ){
            if(callErrorMap.get(c)==1){
                c.addError('You ve exceeded your limit for this call');
            }
        }
    }        
  }
}

Best Answer

This error arises when you try to call addError in a trigger but call it on a record that is not in the trigger collection, which is exactly what you are doing. You can only validate records that are being acted on.