TriggerContext Class

Provides information about the platform event trigger that’s currently executing, such as how many times the trigger was retried due to the EventBus.RetryableException.

Namespace

EventBus

TriggerContext Properties

The following are properties for TriggerContext.

  • lastError
    Read-only. The error message that the last thrown EventBus.RetryableException contains.
  • retries
    Read-only. The number of times the trigger was retried due to throwing the EventBus.RetryableException.

lastError

Read-only. The error message that the last thrown EventBus.RetryableException contains.

Signature

public String lastError {get;}

Property Value

Type: String

Usage

The error message that this property returns is the message that was passed in when creating the EventBus.RetryableException exception, as follows.

throw new EventBus.RetryableException(
             'Condition is not met, so retrying the trigger again.');

retries

Read-only. The number of times the trigger was retried due to throwing the EventBus.RetryableException.

Signature

public Integer retries {get;}

Property Value

Type: Integer

TriggerContext Methods

The following are methods for TriggerContext.

  • currentContext()
    Returns an instance of the EventBus.TriggerContext class containing information about the currently executing trigger.

currentContext()

Returns an instance of the EventBus.TriggerContext class containing information about the currently executing trigger.

Signature

public static eventbus.TriggerContext currentContext()

Return Value

Type: EventBus.TriggerContext

Information about the currently executing trigger.