Fixed server crashes from stores' prepared statements.

This commit is contained in:
Tom 2024-10-31 19:09:46 +00:00
parent 5618b28c49
commit 4979553c74

View File

@ -21,6 +21,8 @@ namespace HermesSocketServer.Store
} }
public async Task DoPreparedStatement<V>(Database database, string sql, IEnumerable<V> values, string[] columns) public async Task DoPreparedStatement<V>(Database database, string sql, IEnumerable<V> values, string[] columns)
{
try
{ {
await database.Execute(sql, (c) => await database.Execute(sql, (c) =>
{ {
@ -36,8 +38,15 @@ namespace HermesSocketServer.Store
} }
}); });
} }
catch (Exception ex)
{
_logger.Error(ex, "Failed to execute a prepared statement: " + sql);
}
}
public async Task DoPreparedStatementRaw<V>(Database database, string sql, IEnumerable<V> values, string[] columns) public async Task DoPreparedStatementRaw<V>(Database database, string sql, IEnumerable<V> values, string[] columns)
{
try
{ {
await database.Execute(sql, (c) => await database.Execute(sql, (c) =>
{ {
@ -53,6 +62,11 @@ namespace HermesSocketServer.Store
} }
}); });
} }
catch (Exception ex)
{
_logger.Error(ex, "Failed to execute a prepared statement: " + sql);
}
}
public string GenerateInsertSql(string table, IEnumerable<T> values, IEnumerable<string> columns) public string GenerateInsertSql(string table, IEnumerable<T> values, IEnumerable<string> columns)
{ {