Skip to main content

Overview

ErrorLogger is a production-safe Apex utility class included in the Zentien package. It publishes errors as ErrorEvent__e Platform Events, which Zentien receives and stores in real time. Design principles:
  • Never throws — all methods are wrapped in try/catch. A failure to log will never break your calling code.
  • No callout limits consumed — Platform Events use a separate publish limit (not the callout limit)
  • Synchronous publish — errors appear in Zentien within seconds

Methods

log(Exception e, String className, String methodName)

Logs an exception with ERROR severity.
ErrorLogger.log(e, 'MyClass', 'myMethod');
ParameterTypeDescription
eExceptionThe caught exception
classNameStringName of the class where the error occurred
methodNameStringName of the method where the error occurred

log(Exception e, String className, String methodName, String severity)

Logs an exception with a specified severity.
ErrorLogger.log(e, 'MyClass', 'myMethod', 'CRITICAL');
ParameterTypeDescription
severityStringOne of: INFO, WARNING, ERROR, CRITICAL

log(Exception e, String className, String methodName, String severity, String recordId)

Logs an exception with severity and a related Salesforce record ID for additional context.
ErrorLogger.log(e, 'MyClass', 'myMethod', 'ERROR', recordId);
ParameterTypeDescription
recordIdStringID of the related Salesforce record (optional context)

ErrorEvent__e fields

The Platform Event published by ErrorLogger contains the following fields:
FieldDescription
OrgId__cThe Salesforce Org ID
EventType__cAlways HANDLED when logged via ErrorLogger
AutomationType__cApex
AutomationName__cThe className parameter
MethodName__cThe methodName parameter
ErrorMessage__cThe exception message
StackTrace__cThe exception stack trace
RecordId__cThe recordId parameter (if provided)
UserId__cThe ID of the running user
Severity__cThe severity level
Environment__cproduction or sandbox