1
0
mirror of synced 2024-11-24 04:20:10 +01:00
TaikoSoundEditor/Utils/ExceptionGuard.cs

32 lines
732 B
C#
Raw Normal View History

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
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
}
}