Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Better Error Messages #101

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/SqlStreamStore.Server/SqlStreamStoreInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ private async Task InitializeMySqlStreamStore(CancellationToken cancellationToke
{
await streamStore.CreateSchemaIfNotExists(cancellationToken);
}
catch (MySqlException ex)
catch (MySqlException)
{
SchemaCreationFailed(streamStore.GetSchemaCreationScript, ex);
SchemaCreationFailed(streamStore.GetSchemaCreationScript);
throw;
}
}
}
Expand All @@ -67,9 +68,10 @@ private async Task InitializeMsSqlStreamStore(CancellationToken cancellationToke
{
await streamStore.CreateSchemaIfNotExists(cancellationToken);
}
catch (SqlException ex)
catch (SqlException)
{
SchemaCreationFailed(streamStore.GetSchemaCreationScript, ex);
SchemaCreationFailed(streamStore.GetSchemaCreationScript);
throw;
}
}
}
Expand All @@ -82,27 +84,26 @@ private async Task InitializePostgresStreamStore(CancellationToken cancellationT
{
await streamStore.CreateSchemaIfNotExists(cancellationToken);
}
catch (NpgsqlException ex)
catch (NpgsqlException)
{
SchemaCreationFailed(streamStore.GetSchemaCreationScript, ex);
SchemaCreationFailed(streamStore.GetSchemaCreationScript);
throw;
}
}
}

private static void SchemaCreationFailed(Func<string> getSchemaCreationScript, Exception ex)
private static void SchemaCreationFailed(Func<string> getSchemaCreationScript)
{
s_Log.Error(
new StringBuilder()
.Append("Could not create schema: {ex}")
.Append("Could not create schema.")
.AppendLine()
.Append(
"Does your connection string have enough permissions? If not, run the following sql script as a privileged user:")
.AppendLine()
.Append("{script}")
.ToString(),
ex,
getSchemaCreationScript());
Environment.Exit(1);
}
}
}