Click or drag to resize

LoggerSwallowT Method (FuncT, T)

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.

Namespace:  NLog
Assembly:  NLog (in NLog.dll) Version: 5.5.0+1873145cbc26e0312d9481234d69ce7dc68aac4e
Syntax
public T Swallow<T>(
	Func<T> func,
	T fallback
)

Parameters

func
Type: SystemFuncT
Function to run.
fallback
Type: T
Fallback value to return in case of exception.

Type Parameters

T
Return type of the provided function.

Return Value

Type: T
Result returned by the provided function or fallback value in case of exception.

Implements

ISuppress.Swallow``1(FuncUMP, UMP)
See Also