1
0
mirror of synced 2024-12-18 04:45:55 +01:00
TaikoSoundEditor/Commons/Utils/ExceptionGuard.cs

29 lines
666 B
C#
Raw Normal View History

2023-07-28 18:02:47 +02:00
using System;
2023-10-01 18:40:41 +02:00
using System.Windows.Forms;
2023-07-28 18:02:47 +02:00
2023-10-01 18:40:41 +02:00
namespace TaikoSoundEditor.Commons.Utils
2023-07-28 18:02:47 +02:00
{
internal static class ExceptionGuard
{
public static void Run(Action action)
{
try
{
action();
}
catch (Exception ex)
{
2023-07-31 19:17:21 +02:00
#if DEBUG
Logger.Error(ex);
if (MessageBox.Show(ex.Message + "\n\nThrow?", "An error occured", MessageBoxButtons.YesNo) == DialogResult.Yes)
throw;
#else
2023-07-28 18:02:47 +02:00
MessageBox.Show(ex.Message, "An error occured");
Logger.Error(ex);
2023-07-31 19:17:21 +02:00
#endif
}
}
2023-07-28 18:02:47 +02:00
}
}