Improved error handling in interview database functions
This commit is contained in:
parent
839ec527df
commit
ebd279da45
1 changed files with 14 additions and 5 deletions
15
Database.cs
15
Database.cs
|
@ -772,9 +772,9 @@ public static class Database
|
||||||
{
|
{
|
||||||
Error = delegate (object sender, ErrorEventArgs args)
|
Error = delegate (object sender, ErrorEventArgs args)
|
||||||
{
|
{
|
||||||
Logger.Error("Exception occured when trying to read interview from database:\n" + args.ErrorContext.Error.Message);
|
Logger.Error("Error occured when trying to read interview templates from database: " + args.ErrorContext.Error.Message);
|
||||||
Logger.Debug("Detailed exception:", args.ErrorContext.Error);
|
Logger.Debug("Detailed exception:", args.ErrorContext.Error);
|
||||||
args.ErrorContext.Handled = true;
|
args.ErrorContext.Handled = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -823,12 +823,21 @@ public static class Database
|
||||||
Dictionary<ulong, Interviewer.InterviewQuestion> questions = new();
|
Dictionary<ulong, Interviewer.InterviewQuestion> questions = new();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// Channel ID 0 is the interview template
|
try
|
||||||
|
{
|
||||||
|
// Channel ID 0 is the interview template, don't read it here.
|
||||||
if (results.GetUInt64("channel_id") != 0)
|
if (results.GetUInt64("channel_id") != 0)
|
||||||
{
|
{
|
||||||
questions.Add(results.GetUInt64("channel_id"), JsonConvert.DeserializeObject<Interviewer.InterviewQuestion>(results.GetString("interview")));
|
questions.Add(results.GetUInt64("channel_id"), JsonConvert.DeserializeObject<Interviewer.InterviewQuestion>(results.GetString("interview")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Error("Error occured when trying to read interview from database, it will not be loaded until manually fixed in the database.\nError message: " + e.Message);
|
||||||
|
Logger.Debug("Detailed exception:", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
while (results.Read());
|
while (results.Read());
|
||||||
results.Close();
|
results.Close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue