Skip to content

Class ExceptionHandlingFrame

Namespace: Momentum.ServiceDefaults.Messaging.Middlewares
Assembly: Momentum.ServiceDefaults.dll

Wolverine code generation frame that wraps message handlers in try-catch blocks for exception handling.

csharp
public class ExceptionHandlingFrame : SyncFrame

Inheritance

object ← Frame ← SyncFrame ← ExceptionHandlingFrame

Inherited Members

Frame.creates, Frame.dependencies, Frame.uses, Frame.Create(Type), Frame.Create<T>(), Frame.Create<T>(string), Frame.GenerateCode(GeneratedMethod, ISourceWriter), Frame.ResolveVariables(IMethodVariables), Frame.FindVariables(IMethodVariables), Frame.CanReturnTask(), Frame.AllFrames(), Frame.IsAsync, Frame.Wraps, Frame.Next, Frame.Uses, Frame.Creates, Frame.Dependencies, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Remarks

This frame generates code that:

  • Wraps the handler execution in a try-catch block
  • Captures any exceptions in the envelope's Failure property
  • Re-throws the exception for Wolverine's error handling pipeline
This ensures that exceptions are properly tracked in the message envelope for logging and metrics purposes while still allowing Wolverine to handle retries and DLQ.

Constructors

ExceptionHandlingFrame()

csharp
public ExceptionHandlingFrame()

Methods

FindVariables(IMethodVariables)

Identifies required variables for code generation.

csharp
public override IEnumerable<Variable> FindVariables(IMethodVariables chain)

Parameters

chain IMethodVariables

The method variables available in the handler chain.

Returns

IEnumerable<Variable>

The envelope variable needed for exception tracking.

GenerateCode(GeneratedMethod, ISourceWriter)

Generates the try-catch code wrapping for exception handling.

csharp
public override void GenerateCode(GeneratedMethod method, ISourceWriter writer)

Parameters

method GeneratedMethod

The generated method being built.

writer ISourceWriter

The source code writer.