Skip to content

Commit

Permalink
Error handling improvement loading GUI config
Browse files Browse the repository at this point in the history
Replace type initializer exception with something useful. #931
  • Loading branch information
DavidWiseman committed Jul 10, 2024
1 parent e4bb582 commit 1995553
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion DBADashGUI/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DBADash;
using DocumentFormat.OpenXml;
using Microsoft.Data.SqlClient;
Expand Down Expand Up @@ -34,7 +35,20 @@ internal static class Config

static Config()
{
RefreshConfig();
try
{
RefreshConfig();
}
catch (SqlException ex) when (ex.Number == 229)
{
MessageBox.Show(ex.Message + "\n\nThe App or AppReadOnly role can be used to grant access to the GUI", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
catch (Exception ex)
{
MessageBox.Show("Error getting application settings\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
}

public static void RefreshConfig()
Expand Down

0 comments on commit 1995553

Please sign in to comment.