Better debug messages & some error handling
This commit is contained in:
parent
b45aaeedc7
commit
25ec0452a4
|
@ -20,7 +20,7 @@ public class Database
|
|||
{
|
||||
if (File.Exists($"{Name}.json"))
|
||||
{
|
||||
Console.WriteLine($"{Name} flag123");
|
||||
Console.WriteLine($"[{Name}] The file exists.");
|
||||
var json = File.ReadAllText($"{Name}.json");
|
||||
var db = JsonConvert.DeserializeObject<List<Table>>(json);
|
||||
if (db != null)
|
||||
|
@ -28,14 +28,23 @@ public class Database
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"{Name} flag");
|
||||
Console.WriteLine($"[{Name}] The file is getting created.");
|
||||
File.Create($"{Name}.json");
|
||||
}
|
||||
}
|
||||
public void Save()
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(_tables);
|
||||
File.WriteAllText($"{Name}.json", json);
|
||||
try
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(_tables);
|
||||
File.WriteAllText($"{Name}.json", json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// slim chance there might be file structure issues.
|
||||
// let's attempt to fix that.
|
||||
SetupFiles();
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateTable(Table query)
|
||||
|
|
Loading…
Reference in New Issue