2023-07-28 18:02:47 +02:00
|
|
|
|
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)
|
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
}
|