namespace Sandbox;
public static partial class SandboxSystemExtensions
{
///
/// Call an action, swallow any exceptions with a warning
///
public static void InvokeWithWarning( this Action action )
{
if ( action is null ) return;
try
{
action.Invoke();
}
catch ( System.Exception e )
{
Log.Warning( e, $"{e.Message}" );
}
}
///
/// Call an action, swallow any exceptions with a warning
///
public static void InvokeWithWarning( this Action action, T arg0 )
{
if ( action is null ) return;
try
{
action.Invoke( arg0 );
}
catch ( System.Exception e )
{
Log.Warning( e, $"{e.Message}" );
}
}
///
/// Call an action, swallow any exceptions with a warning
///
public static void InvokeWithWarning( this Action action, T1 arg0, T2 arg1 )
{
if ( action is null ) return;
try
{
action.Invoke( arg0, arg1 );
}
catch ( System.Exception e )
{
Log.Warning( e, $"{e.Message}" );
}
}
}