I've set out to build a custom error handling and logging feature for my org wherein all apex exceptions will be logged into a custom sObject for analysis and follow-up.
public class TriggerException extends Exception {
public TriggerException(String message, Exception ex, String className, String methodName) {
this(message, ex);
ExceptionLog__c log = new ExceptionLog__c(
ClassName__c = className,
MethodName__c = methodName,
ErrorLine__c = errorLine,
ErrorMessage__c = errorMessage,
ErrorDetails__c = errorStackTrace,
ErrorType__c = errorType
);
insert log;
}
}
However, this doesn't ever seem to save the ExceptionLog__c
and I'm assuming it's because it's also caught up in the same database rollback procedure as the rest of the code...
How can I do this without having to add UtilClass.logMe(...);
to every catch {}
block in my org??