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

Commit f904bc2

Browse files
Merge pull request #101 from thefringeninja/better-error-messages
Better Error Messages
2 parents 1c671c7 + 73b1072 commit f904bc2

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/SqlStreamStore.Server/SqlStreamStoreInitializer.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ private async Task InitializeMySqlStreamStore(CancellationToken cancellationToke
5252
{
5353
await streamStore.CreateSchemaIfNotExists(cancellationToken);
5454
}
55-
catch (MySqlException ex)
55+
catch (MySqlException)
5656
{
57-
SchemaCreationFailed(streamStore.GetSchemaCreationScript, ex);
57+
SchemaCreationFailed(streamStore.GetSchemaCreationScript);
58+
throw;
5859
}
5960
}
6061
}
@@ -67,9 +68,10 @@ private async Task InitializeMsSqlStreamStore(CancellationToken cancellationToke
6768
{
6869
await streamStore.CreateSchemaIfNotExists(cancellationToken);
6970
}
70-
catch (SqlException ex)
71+
catch (SqlException)
7172
{
72-
SchemaCreationFailed(streamStore.GetSchemaCreationScript, ex);
73+
SchemaCreationFailed(streamStore.GetSchemaCreationScript);
74+
throw;
7375
}
7476
}
7577
}
@@ -82,27 +84,26 @@ private async Task InitializePostgresStreamStore(CancellationToken cancellationT
8284
{
8385
await streamStore.CreateSchemaIfNotExists(cancellationToken);
8486
}
85-
catch (NpgsqlException ex)
87+
catch (NpgsqlException)
8688
{
87-
SchemaCreationFailed(streamStore.GetSchemaCreationScript, ex);
89+
SchemaCreationFailed(streamStore.GetSchemaCreationScript);
90+
throw;
8891
}
8992
}
9093
}
9194

92-
private static void SchemaCreationFailed(Func<string> getSchemaCreationScript, Exception ex)
95+
private static void SchemaCreationFailed(Func<string> getSchemaCreationScript)
9396
{
9497
s_Log.Error(
9598
new StringBuilder()
96-
.Append("Could not create schema: {ex}")
99+
.Append("Could not create schema.")
97100
.AppendLine()
98101
.Append(
99102
"Does your connection string have enough permissions? If not, run the following sql script as a privileged user:")
100103
.AppendLine()
101104
.Append("{script}")
102105
.ToString(),
103-
ex,
104106
getSchemaCreationScript());
105-
Environment.Exit(1);
106107
}
107108
}
108109
}

0 commit comments

Comments
 (0)