mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-15 17:59:22 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
57 lines
1.0 KiB
C#
57 lines
1.0 KiB
C#
|
|
namespace Sandbox;
|
|
|
|
public static partial class SandboxSystemExtensions
|
|
{
|
|
/// <summary>
|
|
/// Call an action, swallow any exceptions with a warning
|
|
/// </summary>
|
|
public static void InvokeWithWarning( this Action action )
|
|
{
|
|
if ( action is null ) return;
|
|
|
|
try
|
|
{
|
|
action.Invoke();
|
|
}
|
|
catch ( System.Exception e )
|
|
{
|
|
Log.Warning( e, $"{e.Message}" );
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Call an action, swallow any exceptions with a warning
|
|
/// </summary>
|
|
public static void InvokeWithWarning<T>( this Action<T> action, T arg0 )
|
|
{
|
|
if ( action is null ) return;
|
|
|
|
try
|
|
{
|
|
action.Invoke( arg0 );
|
|
}
|
|
catch ( System.Exception e )
|
|
{
|
|
Log.Warning( e, $"{e.Message}" );
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Call an action, swallow any exceptions with a warning
|
|
/// </summary>
|
|
public static void InvokeWithWarning<T1, T2>( this Action<T1, T2> action, T1 arg0, T2 arg1 )
|
|
{
|
|
if ( action is null ) return;
|
|
|
|
try
|
|
{
|
|
action.Invoke( arg0, arg1 );
|
|
}
|
|
catch ( System.Exception e )
|
|
{
|
|
Log.Warning( e, $"{e.Message}" );
|
|
}
|
|
}
|
|
}
|