1
0
mirror of synced 2024-11-30 14:14:29 +01:00
TaikoSoundEditor/Utils/ExceptionGuard.cs
2023-08-16 19:05:50 +03:00

32 lines
732 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TaikoSoundEditor.Utils
{
internal static class ExceptionGuard
{
public static void Run(Action action)
{
try
{
action();
}
catch (Exception ex)
{
#if DEBUG
Logger.Error(ex);
if (MessageBox.Show(ex.Message + "\n\nThrow?", "An error occured", MessageBoxButtons.YesNo) == DialogResult.Yes)
throw;
#else
MessageBox.Show(ex.Message, "An error occured");
Logger.Error(ex);
#endif
}
}
}
}