I know the error 'SObject row was retrieved via SOQL without querying the requested field:XYZ' comes up when we try to access an object field without adding it(XYZ) in the SOQL query. I need a way to handle this exception.
I have written the apex logic in a try block and when any exception was caught, triggers an email to admins so that they can quickly look into it.
But, as this exception was not thrown in the apex code, we haven't received any email. Is there a way to handle this sort of exceptions / errors? Some way, if a mail can be triggered to certain users is sufficient.