Show proper error at db connect fail
This commit is contained in:
parent
0e30335a7a
commit
76597fce37
1 changed files with 13 additions and 6 deletions
|
|
@ -60,14 +60,21 @@ namespace TShockAPI.DB
|
||||||
public static QueryResult QueryReader(this IDbConnection olddb, string query, params object[] args)
|
public static QueryResult QueryReader(this IDbConnection olddb, string query, params object[] args)
|
||||||
{
|
{
|
||||||
var db = olddb.CloneEx();
|
var db = olddb.CloneEx();
|
||||||
db.Open();
|
try
|
||||||
using (var com = db.CreateCommand())
|
|
||||||
{
|
{
|
||||||
com.CommandText = query;
|
db.Open();
|
||||||
for (int i = 0; i < args.Length; i++)
|
using (var com = db.CreateCommand())
|
||||||
com.AddParameter("@" + i, args[i]);
|
{
|
||||||
|
com.CommandText = query;
|
||||||
|
for (int i = 0; i < args.Length; i++)
|
||||||
|
com.AddParameter("@" + i, args[i]);
|
||||||
|
|
||||||
return new QueryResult(db, com.ExecuteReader());
|
return new QueryResult(db, com.ExecuteReader());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("Fatal TShock initialization exception: failed to connect to MySQL database. See inner exception for details.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue