public Event returnEventOppObj(Opportunity opp1, Sobject sobj){
Event e2 = New Event(Subject='Call1',Type = 'Call1', StartDateTime = datetime.now(), EndDateTime = datetime.now(), Ownerid =userinfo.getUserId(), WhatId=opp1.id, WhoId=sobj.Id);
return e2;
}
if I call this method where sObject is Lead, it will throwing exception as:
FIELD_INTEGRITY_EXCEPTION, You can't relate a lead to an account or other object.: [WhatId]