Improved error handling of import process

This commit is contained in:
tsommer committed 2023-01-22 21:05:13 +01:00
1 parent caaa00f116
commit ce5f2ae401
1 file changed
+7 -2
+7 -2
View File
@@ -47,11 +47,16 @@ internal static class Program
{ {
serviceCollection.ImportDataAndAddDatabase(loader.Result.DataFile).ConfigureAwait(false).GetAwaiter().GetResult(); serviceCollection.ImportDataAndAddDatabase(loader.Result.DataFile).ConfigureAwait(false).GetAwaiter().GetResult();
} }
catch (JsonException) catch (JsonException e)
{ {
MessageBox.Show($"The JSON file '{loader.Result.DataFile}' is invalid and cannot be imported.", "Invalid JSON file", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show($"The JSON file '{loader.Result.DataFile}' is invalid and cannot be imported: {e.Message}", "Invalid JSON file", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(100); Environment.Exit(100);
} }
catch(Exception e)
{
MessageBox.Show($"An error occurred while importing the JSON file '{loader.Result.DataFile}': {e.Message}", "Error while importing JSON file", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(101);
}
} }
}); });