mirror of
https://github.com/vrcx-team/VRCX.git
synced 2026-04-06 00:32:02 +02:00
Refactor SQLite to inform user of database errors
This commit is contained in:
@@ -44,26 +44,15 @@ namespace VRCX
|
||||
m_Connection.Close();
|
||||
m_Connection.Dispose();
|
||||
}
|
||||
|
||||
public string ExecuteJson(string sql, IDictionary<string, object> args = null)
|
||||
|
||||
// for Electron
|
||||
public string ExecuteJson(string sql, IDictionary<string, object>? args = null)
|
||||
{
|
||||
var result = Execute(sql, args);
|
||||
if (result.Item1 != null)
|
||||
{
|
||||
return JsonSerializer.Serialize(new
|
||||
{
|
||||
status = "error",
|
||||
message = result.Item1
|
||||
});
|
||||
}
|
||||
return JsonSerializer.Serialize(new
|
||||
{
|
||||
status = "success",
|
||||
data = result.Item2
|
||||
});
|
||||
return JsonSerializer.Serialize(result);
|
||||
}
|
||||
|
||||
public Tuple<string, object[]> Execute(string sql, IDictionary<string, object> args = null)
|
||||
public object[][] Execute(string sql, IDictionary<string, object>? args = null)
|
||||
{
|
||||
m_ConnectionLock.EnterReadLock();
|
||||
try
|
||||
@@ -88,11 +77,7 @@ namespace VRCX
|
||||
}
|
||||
result.Add(values);
|
||||
}
|
||||
return new Tuple<string, object[]>(null, result.ToArray());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new Tuple<string, object[]>(ex.Message, null);
|
||||
return result.ToArray();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -100,9 +85,9 @@ namespace VRCX
|
||||
}
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(string sql, IDictionary<string, object> args = null)
|
||||
public int ExecuteNonQuery(string sql, IDictionary<string, object>? args = null)
|
||||
{
|
||||
int result = -1;
|
||||
var result = -1;
|
||||
m_ConnectionLock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace VRCX
|
||||
);
|
||||
try
|
||||
{
|
||||
var item = (object[])values.Item2[0];
|
||||
var item = values[0];
|
||||
using var stream = new MemoryStream(Convert.FromBase64String((string)item[0]));
|
||||
_cookieContainer = new CookieContainer();
|
||||
_cookieContainer.Add(System.Text.Json.JsonSerializer.Deserialize<CookieCollection>(stream));
|
||||
|
||||
Reference in New Issue
Block a user