<PackageReference Include="NLog" Version="6.1.0" />

NLog.ISuppress

public interface ISuppress
Obsolete and replaced by ILogger with NLog v5.3. Provides an interface to execute System.Actions without surfacing any exceptions raised for that action.
void Swallow(Action action)

Runs the provided action. If the action throws, the exception is logged at Error level. The exception is not propagated outside of this method.

T Swallow<T>(Func<T> func)

Runs the provided function and returns its result. If an exception is thrown, it is logged at Error level. The exception is not propagated outside of this method; a default value is returned instead.

T Swallow<T>(Func<T> func, T fallback)

Runs the provided function and returns its result. If an exception is thrown, it is logged at Error level. The exception is not propagated outside of this method; a fallback value is returned instead.

void Swallow(Task task)

Logs an exception is logged at Error level if the provided task does not run to completion.

Returns a task that completes when a specified task to completes. If the task does not run to completion, an exception is logged at Error level. The returned task always runs to completion.

Task SwallowAsync(Func<Task> asyncAction)

Runs async action. If the action throws, the exception is logged at Error level. The exception is not propagated outside of this method.

Task<TResult> SwallowAsync<TResult>(Func<Task<TResult>> asyncFunc)

Runs the provided async function and returns its result. If the task does not run to completion, an exception is logged at Error level. The exception is not propagated outside of this method; a default value is returned instead.

Task<TResult> SwallowAsync<TResult>(Func<Task<TResult>> asyncFunc, TResult fallback)

Runs the provided async function and returns its result. If the task does not run to completion, an exception is logged at Error level. The exception is not propagated outside of this method; a fallback value is returned instead.