1
0
mirror of synced 2024-11-23 20:10:57 +01:00
TaikoSoundEditor/Commons/Utils/ExceptionGuard.cs
2023-10-01 19:40:41 +03:00

29 lines
666 B
C#

using System;
using System.Windows.Forms;
namespace TaikoSoundEditor.Commons.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
}
}
}
}