-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the missing
Exception
parameter in `IAsyncMessageErrorHandler[T…
…Message, TMessageResult]` and `IAsyncMessageErrorHandler[TMessage]` interfaces.
- Loading branch information
Showing
12 changed files
with
52 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 21 additions & 16 deletions
37
...ssaging.Abstractions/Handler/Error/IAsyncMessageErrorHandler[TMessage, TMessageResult].cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,39 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace LiteBus.Messaging.Abstractions; | ||
|
||
/// <summary> | ||
/// Defines a contract for an asynchronous message error handler that operates on messages of type <typeparamref name="TMessage"/> and message results of type <typeparamref name="TMessageResult"/>. | ||
/// Represents an asynchronous error handler for messages of type <typeparamref name="TMessage"/> | ||
/// and results of type <typeparamref name="TMessageResult"/>. | ||
/// This interface should be implemented to handle exceptions that occur during the processing of messages. | ||
/// </summary> | ||
/// <typeparam name="TMessage">The type of the message that this handler can process.</typeparam> | ||
/// <typeparam name="TMessageResult">The type of the message result that this handler deals with.</typeparam> | ||
/// <typeparam name="TMessage">The type of the message that this error handler is applicable to.</typeparam> | ||
/// <typeparam name="TMessageResult">The type of the result produced by the message processing.</typeparam> | ||
public interface IAsyncMessageErrorHandler<in TMessage, in TMessageResult> : IMessageErrorHandler<TMessage, TMessageResult> | ||
{ | ||
/// <summary> | ||
/// Synchronously handles an error occurring during message processing using the default error handling strategy, by internally calling the asynchronous <see cref="HandleErrorAsync(TMessage, TMessageResult, CancellationToken)"/> method. | ||
/// Synchronously handles an error encountered in message processing by delegating to an asynchronous method. | ||
/// </summary> | ||
/// <param name="message">The message that was being processed when the error occurred.</param> | ||
/// <param name="exception"></param> | ||
/// <param name="messageResult">The result of the message processing that led to the error, of type <typeparamref name="TMessageResult"/>.</param> | ||
/// <returns>The result of handling the error, potentially modified or enriched with additional information.</returns> | ||
object IMessageErrorHandler<TMessage, TMessageResult>.HandleError(TMessage message, Exception exception, TMessageResult messageResult) | ||
/// <param name="message">The message that encountered the error.</param> | ||
/// <param name="exception">The exception that was thrown during message processing.</param> | ||
/// <param name="messageResult">The result of the message processing prior to the error, which may be null.</param> | ||
/// <returns>A placeholder object returned after handling the error.</returns> | ||
object IMessageErrorHandler<TMessage, TMessageResult>.HandleError(TMessage message, Exception exception, TMessageResult? messageResult) | ||
{ | ||
return HandleErrorAsync(message, messageResult, AmbientExecutionContext.Current?.CancellationToken ?? throw new NoExecutionContextException()); | ||
return HandleErrorAsync(message, messageResult, exception, AmbientExecutionContext.Current?.CancellationToken ?? throw new NoExecutionContextException()); | ||
} | ||
|
||
/// <summary> | ||
/// Asynchronously handles an error that occurred during the processing of a message, potentially altering the result based on the error handling logic implemented. | ||
/// Asynchronously handles an error encountered in message processing. | ||
/// </summary> | ||
/// <param name="message">The message that was being processed when the error occurred, of type <typeparamref name="TMessage"/>.</param> | ||
/// <param name="messageResult">The result of the message processing that led to the error, of type <typeparamref name="TMessageResult"/>.</param> | ||
/// <param name="cancellationToken">A token to monitor for cancellation requests, allowing this method to be exited prematurely if necessary. Defaults to <see cref="CancellationToken.None"/>.</param> | ||
/// <returns>A <see cref="Task"/> representing the asynchronous operation, potentially altering the message result based on the error handling logic implemented.</returns> | ||
Task HandleErrorAsync(TMessage message, TMessageResult messageResult, CancellationToken cancellationToken = default); | ||
/// <param name="message">The message that encountered the error.</param> | ||
/// <param name="messageResult">The result of the message processing prior to the error, which may be null.</param> | ||
/// <param name="exception">The exception that was thrown during message processing.</param> | ||
/// <param name="cancellationToken">A token for cancelling the error handling operation.</param> | ||
/// <returns>A task representing the asynchronous error handling operation.</returns> | ||
Task HandleErrorAsync(TMessage message, TMessageResult? messageResult, Exception exception, CancellationToken cancellationToken = default); | ||
} |
33 changes: 19 additions & 14 deletions
33
src/LiteBus.Messaging.Abstractions/Handler/Error/IAsyncMessageErrorHandler[TMessage].cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace LiteBus.Messaging.Abstractions; | ||
|
||
/// <summary> | ||
/// Defines a contract for an asynchronous message error handler that operates on messages of type <typeparamref name="TMessage"/>. | ||
/// Represents an asynchronous error handler for messages of type <typeparamref name="TMessage"/>. | ||
/// This interface should be implemented to handle exceptions that occur during message processing. | ||
/// </summary> | ||
/// <typeparam name="TMessage">The type of the message that this handler can process.</typeparam> | ||
/// <typeparam name="TMessage">The type of the message that this error handler is applicable to.</typeparam> | ||
public interface IAsyncMessageErrorHandler<in TMessage> : IMessageErrorHandler<TMessage, object> | ||
{ | ||
/// <summary> | ||
/// Synchronously handles an error occurring during message processing using the default error handling strategy, by internally calling the asynchronous <see cref="HandleErrorAsync(TMessage, CancellationToken)"/> method. | ||
/// Synchronously handles an error encountered in message processing by delegating to an asynchronous method. | ||
/// </summary> | ||
/// <param name="message">The message that was being processed when the error occurred.</param> | ||
/// <param name="exception"></param> | ||
/// <param name="messageResult">The result of the message processing that led to the error, if any.</param> | ||
/// <returns>The result of handling the error, potentially modified or enriched with additional information.</returns> | ||
object IMessageErrorHandler<TMessage, object>.HandleError(TMessage message, Exception exception, object messageResult) | ||
/// <param name="message">The message that encountered the error.</param> | ||
/// <param name="exception">The exception that was thrown during message processing.</param> | ||
/// <param name="messageResult">The result of the message processing prior to the error.</param> | ||
/// <returns>A placeholder object returned after handling the error.</returns> | ||
object IMessageErrorHandler<TMessage, object>.HandleError(TMessage message, Exception exception, object? messageResult) | ||
{ | ||
return HandleErrorAsync(message, AmbientExecutionContext.Current?.CancellationToken ?? throw new NoExecutionContextException()); | ||
return HandleErrorAsync(message, messageResult, exception, AmbientExecutionContext.Current?.CancellationToken ?? throw new NoExecutionContextException()); | ||
} | ||
|
||
/// <summary> | ||
/// Asynchronously handles an error that occurred during the processing of a message. | ||
/// Asynchronously handles an error encountered in message processing. | ||
/// </summary> | ||
/// <param name="message">The message that was being processed when the error occurred.</param> | ||
/// <param name="cancellationToken">A token to monitor for cancellation requests, allowing this method to be exited prematurely if necessary. Defaults to <see cref="CancellationToken.None"/>.</param> | ||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> | ||
Task HandleErrorAsync(TMessage message, CancellationToken cancellationToken = default); | ||
/// <param name="message">The message that encountered the error.</param> | ||
/// <param name="messageResult">The result of the message processing prior to the error.</param> | ||
/// <param name="exception">The exception that was thrown during message processing.</param> | ||
/// <param name="cancellationToken">A token for cancelling the error handling operation.</param> | ||
/// <returns>A task representing the asynchronous error handling operation.</returns> | ||
Task HandleErrorAsync(TMessage message, object? messageResult, Exception exception, CancellationToken cancellationToken = default); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters