Skip to content

Commit

Permalink
Give helping error message if the application does not start
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikMogensen committed Feb 25, 2024
1 parent 04ee5fe commit d0f13c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Common/Helpers/ConfigurationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void UpdateServiceBusNamespace(ConfigFileUse configFileUse, string
configuration.UpdateEntryInDictionarySection(SERVICEBUS_SECTION_NAME, key, newKey, newValue, writeToLog);
}

public static void F(ConfigFileUse configFileUse, string key, string value, WriteToLogDelegate writeToLog)
public static void AddServiceBusNamespace(ConfigFileUse configFileUse, string key, string value, WriteToLogDelegate writeToLog)
{
var configuration = TwoFilesConfiguration.Create(configFileUse, writeToLog);

Expand Down
9 changes: 8 additions & 1 deletion src/ServiceBusExplorer/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4041,7 +4041,14 @@ private void SetTitle(string prefix)
#region Public Static Methods
public static void StaticWriteToLog(string message, bool async = true)
{
mainSingletonMainForm.WriteToLog(message);
if(null != mainSingletonMainForm)
{
mainSingletonMainForm.WriteToLog(message);
}
else
{
MessageBox.Show(message);
}
}
#endregion

Expand Down
11 changes: 10 additions & 1 deletion src/ServiceBusExplorer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,16 @@ static void HandleException(Exception ex)
{
if (ex != null && !string.IsNullOrWhiteSpace(ex.Message))
{
MainForm.StaticWriteToLog(string.Format(CultureInfo.CurrentCulture, ExceptionFormat, ex.Message));
var message = ex.Message;

if (ex.GetType() == typeof(TypeInitializationException))
{
message += Environment.NewLine + Environment.NewLine +
"This may be due to an invalid configuration file.";
}

MainForm.StaticWriteToLog(string.Format(CultureInfo.CurrentCulture, ExceptionFormat, message));

if (ex.InnerException != null && !string.IsNullOrWhiteSpace(ex.InnerException.Message))
{
MainForm.StaticWriteToLog(string.Format(CultureInfo.CurrentCulture, InnerExceptionFormat, ex.InnerException.Message));
Expand Down

0 comments on commit d0f13c5

Please sign in to comment.