This commit is contained in:
JustArchi
2019-04-04 22:34:58 +02:00
parent 44c5bf4ad5
commit 3e4a08d81c
4 changed files with 38 additions and 4 deletions

View File

@@ -315,7 +315,15 @@ namespace ArchiSteamFarm {
BotConfig botConfig;
try {
botConfig = JsonConvert.DeserializeObject<BotConfig>(await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false));
string json = await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false);
if (string.IsNullOrEmpty(json)) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsEmpty, nameof(json)));
return null;
}
botConfig = JsonConvert.DeserializeObject<BotConfig>(json);
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);

View File

@@ -27,6 +27,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using ArchiSteamFarm.Collections;
using ArchiSteamFarm.Localization;
using JetBrains.Annotations;
using Newtonsoft.Json;
using SteamKit2;
@@ -156,7 +157,15 @@ namespace ArchiSteamFarm {
BotDatabase botDatabase;
try {
botDatabase = JsonConvert.DeserializeObject<BotDatabase>(await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false));
string json = await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false);
if (string.IsNullOrEmpty(json)) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsEmpty, nameof(json)));
return null;
}
botDatabase = JsonConvert.DeserializeObject<BotDatabase>(json);
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);

View File

@@ -286,7 +286,15 @@ namespace ArchiSteamFarm {
GlobalConfig globalConfig;
try {
globalConfig = JsonConvert.DeserializeObject<GlobalConfig>(await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false));
string json = await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false);
if (string.IsNullOrEmpty(json)) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsEmpty, nameof(json)));
return null;
}
globalConfig = JsonConvert.DeserializeObject<GlobalConfig>(json);
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);

View File

@@ -26,6 +26,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ArchiSteamFarm.Localization;
using ArchiSteamFarm.SteamKit2;
using JetBrains.Annotations;
using Newtonsoft.Json;
@@ -84,7 +85,15 @@ namespace ArchiSteamFarm {
GlobalDatabase globalDatabase;
try {
globalDatabase = JsonConvert.DeserializeObject<GlobalDatabase>(await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false));
string json = await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false);
if (string.IsNullOrEmpty(json)) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsEmpty, nameof(json)));
return null;
}
globalDatabase = JsonConvert.DeserializeObject<GlobalDatabase>(json);
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);