Improved error handling of import process

This commit is contained in:
Thorsten Sommer 2023-01-22 21:05:13 +01:00
parent caaa00f116
commit ce5f2ae401
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

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