Class TaskExtensions
Namespace: Void.Proxy.Api.Extensions
Assembly: Void.Proxy.Api.dll
public static class TaskExtensionsInheritance
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Methods
CatchExceptions(Task, ILogger, string)
Attaches a continuation that logs failures or cancellations from task and returns the continuation task.
public static Task CatchExceptions(this Task task, ILogger logger, string message)Parameters
task Task
The task to observe for non-successful completion.
logger ILogger
The logger used to emit error messages.
message string
A message prefix included in each error log entry.
Returns
A continuation task that completes after any required logging for task has finished.
Examples
_ = backgroundTask.CatchExceptions(logger, "Background processing failed");
Remarks
The continuation is registered with
For faulted tasks, this method logs completedTask.Exception.InnerException (the first inner exception from the task's
The returned
See Also
Task.ContinueWith(Action<Task>, TaskContinuationOptions), TaskExtensions.CatchExceptions(ValueTask, ILogger, string)
CatchExceptions(ValueTask, ILogger, string)
Converts task to
public static ValueTask CatchExceptions(this ValueTask task, ILogger logger, string message)Parameters
task ValueTask
The value task to observe for non-successful completion.
logger ILogger
The logger used to emit error messages.
message string
A message prefix included in each error log entry.
Returns
A task.
Examples
await valueTask.CatchExceptions(logger, "Link stop handler failed");
Remarks
This overload delegates all logging behavior and error-handling semantics to
The returned task.