1
0
mirror of synced 2025-02-17 11:18:33 +01:00
TaikoSoundEditor/Commons/Utils/ExceptionGuard.cs

29 lines
666 B
C#
Raw Normal View History

2023-07-28 19:02:47 +03:00
using System;
2023-10-01 19:40:41 +03:00
using System.Windows.Forms;
2023-07-28 19:02:47 +03:00
2023-10-01 19:40:41 +03:00
namespace TaikoSoundEditor.Commons.Utils
2023-07-28 19:02:47 +03:00
{
internal static class ExceptionGuard
{
public static void Run(Action action)
{
try
{
action();
}
catch (Exception ex)
{
2023-07-31 20:17:21 +03: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 19:02:47 +03:00
MessageBox.Show(ex.Message, "An error occured");
Logger.Error(ex);
2023-07-31 20:17:21 +03:00
#endif
}
}
2023-07-28 19:02:47 +03:00
}
}