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
19
Database.cs
19
Database.cs
|
@ -772,9 +772,9 @@ public static class Database
|
|||
{
|
||||
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);
|
||||
args.ErrorContext.Handled = true;
|
||||
args.ErrorContext.Handled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -823,11 +823,20 @@ public static class Database
|
|||
Dictionary<ulong, Interviewer.InterviewQuestion> questions = new();
|
||||
do
|
||||
{
|
||||
// Channel ID 0 is the interview template
|
||||
if (results.GetUInt64("channel_id") != 0)
|
||||
try
|
||||
{
|
||||
questions.Add(results.GetUInt64("channel_id"), JsonConvert.DeserializeObject<Interviewer.InterviewQuestion>(results.GetString("interview")));
|
||||
// Channel ID 0 is the interview template, don't read it here.
|
||||
if (results.GetUInt64("channel_id") != 0)
|
||||
{
|
||||
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());
|
||||
results.Close();
|
||||
|
|
Loading…
Reference in a new issue