mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
Catch exception in save method for json class (#5950)
* Catch exception in save method for json class * Update error message * Correct error logging format * Catch IO exception
This commit is contained in:
committed by
GitHub
parent
13d61bd866
commit
cedc4f710e
@@ -118,10 +118,17 @@ namespace Wox.Infrastructure.Storage
|
||||
|
||||
public void Save()
|
||||
{
|
||||
string serialized = JsonConvert.SerializeObject(_data, Formatting.Indented);
|
||||
File.WriteAllText(FilePath, serialized);
|
||||
_storageHelper.Close();
|
||||
Log.Info($"|JsonStorage.Save|Saving cached data| <{FilePath}>");
|
||||
try
|
||||
{
|
||||
string serialized = JsonConvert.SerializeObject(_data, Formatting.Indented);
|
||||
File.WriteAllText(FilePath, serialized);
|
||||
_storageHelper.Close();
|
||||
Log.Info($"|JsonStorage.Save|Saving cached data| <{FilePath}>");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.Error($"|JsonStorage.Save|Error in saving data| <{FilePath}>", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user