Record Class WorkflowError

java.lang.Object
java.lang.Record
io.axoniq.framework.workflow.dsl.api.WorkflowError
Record Components:
type - fully-qualified name of the originating throwable's class.
message - message of the originating throwable, truncated to TRUNCATED_MESSAGE_SIZE characters, or null.
cause - compacted cause, or null.
All Implemented Interfaces:
Cause

@Internal public record WorkflowError(String type, @Nullable String message, @Nullable WorkflowError cause) extends Record implements Cause
Compact, serialization-friendly representation of a Throwable stored in workflow events.

Captures only the exception class name and message — the stack trace is deliberately omitted to keep event-store payloads small and avoid bytecode-incompatibility issues across JVM versions. The full stack trace is still available through the executor logs when the failure occurs.

Since:
5.4.0
Author:
Stefan Dragisic
  • Field Details

    • MAX_CAUSE_DEPTH

      public static final int MAX_CAUSE_DEPTH
      Maximum number of cause-chain levels captured. Protects against deep chains.
      See Also:
    • TRUNCATED_MESSAGE_SIZE

      public static final int TRUNCATED_MESSAGE_SIZE
      Maximum length of message() characters.
      See Also:
  • Constructor Details

    • WorkflowError

      public WorkflowError(String type, @Nullable String message, @Nullable WorkflowError cause)
      Creates an instance of a WorkflowError record class.
      Parameters:
      type - the value for the type record component
      message - the value for the message record component
      cause - the value for the cause record component
  • Method Details

    • from

      public static @Nullable WorkflowError from(@Nullable Throwable throwable)
      Compacts the given throwable and its cause chain (up to MAX_CAUSE_DEPTH levels) into a . Messages longer than TRUNCATED_MESSAGE_SIZE are truncated. Cycles are broken via identity tracking.
      Parameters:
      throwable - throwable to compact, may be null.
      Returns:
      compacted representation, or null if throwable is null.
    • toThrowable

      public RuntimeException toThrowable()
      Rebuilds an exception chain from this compact representation.

      Exceptions thrown by a step body are rebuilt as a stackless WorkflowExecutionException carrying the original exception class FQN and message. The engine-raised StepIndeterminateException is rebuilt as its own type, so a workflow body can catch it after replay exactly as during the run that recorded it. The cause (if any) is reconstructed the same way.

      Returns:
      reconstructed exception.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public String type()
      Returns the value of the type record component.
      Specified by:
      type in interface Cause
      Returns:
      the value of the type record component
    • message

      public @Nullable String message()
      Returns the value of the message record component.
      Specified by:
      message in interface Cause
      Returns:
      the value of the message record component
    • cause

      public @Nullable WorkflowError cause()
      Returns the value of the cause record component.
      Returns:
      the value of the cause record component