Skip to main content

Overview

For errors you catch in a try/catch block, use ErrorLogger.log() to send them to Zentien instantly via Platform Events. There is no email delay — errors appear in your dashboard in real time.

Basic usage

try {
    // your code here
} catch (Exception e) {
    ErrorLogger.log(e, 'YourClassName', 'yourMethodName');
}

Method signatures

// Log an exception with class and method context
ErrorLogger.log(Exception e, String className, String methodName)

// Log with a specific severity level
ErrorLogger.log(Exception e, String className, String methodName, String severity)

// Log with severity and a related record ID
ErrorLogger.log(Exception e, String className, String methodName, String severity, String recordId)

Severity levels

LevelWhen to use
INFONon-critical issues, handled gracefully
WARNINGUnexpected but recoverable
ERRORStandard errors that need attention (default)
CRITICALSevere failures affecting core functionality

Examples

Basic exception logging:
try {
    Account acc = [SELECT Id FROM Account WHERE Id = :recordId];
    update acc;
} catch (Exception e) {
    ErrorLogger.log(e, 'AccountService', 'updateAccount');
}
With severity:
try {
    paymentGateway.charge(amount);
} catch (Exception e) {
    ErrorLogger.log(e, 'PaymentService', 'processPayment', 'CRITICAL');
}
With record context:
try {
    processOrder(orderId);
} catch (Exception e) {
    ErrorLogger.log(e, 'OrderService', 'processOrder', 'ERROR', orderId);
}

Important notes

  • ErrorLogger is designed to never throw. If publishing the Platform Event fails for any reason, the error is silently swallowed — your calling code is never affected.
  • All logging is done asynchronously via Platform Events. There is no performance impact on the transaction that calls it.
  • If you catch an exception and also re-throw it, call ErrorLogger.log() before re-throwing.