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
|
|
|
|
|
2023-08-16 18:05:50 +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
|
|
|
|
}
|
|
|
|
|
}
|