mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Fix handling inventory loading errors
"success" doesn't have to exist as a property in error json
This commit is contained in:
@@ -33,7 +33,7 @@ using Newtonsoft.Json.Linq;
|
||||
namespace ArchiSteamFarm.Steam.Data;
|
||||
|
||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||
internal sealed class InventoryResponse : ResultResponse {
|
||||
internal sealed class InventoryResponse : OptionalResultResponse {
|
||||
[JsonProperty(PropertyName = "assets", Required = Required.DisallowNull)]
|
||||
internal readonly ImmutableHashSet<Asset> Assets = ImmutableHashSet<Asset>.Empty;
|
||||
|
||||
|
||||
35
ArchiSteamFarm/Steam/Data/OptionalResultResponse.cs
Normal file
35
ArchiSteamFarm/Steam/Data/OptionalResultResponse.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
// _ _ _ ____ _ _____
|
||||
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
|
||||
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
|
||||
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
|
||||
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
|
||||
// |
|
||||
// Copyright 2015-2022 Łukasz "JustArchi" Domeradzki
|
||||
// Contact: JustArchi@JustArchi.net
|
||||
// |
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// |
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// |
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using SteamKit2;
|
||||
|
||||
namespace ArchiSteamFarm.Steam.Data;
|
||||
|
||||
[PublicAPI]
|
||||
public class OptionalResultResponse {
|
||||
[JsonProperty(PropertyName = "success", Required = Required.DisallowNull)]
|
||||
public EResult? Result { get; private set; }
|
||||
|
||||
[JsonConstructor]
|
||||
protected OptionalResultResponse() { }
|
||||
}
|
||||
@@ -19,7 +19,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using SteamKit2;
|
||||
@@ -27,7 +26,6 @@ using SteamKit2;
|
||||
namespace ArchiSteamFarm.Steam.Data;
|
||||
|
||||
[PublicAPI]
|
||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||
public class ResultResponse {
|
||||
[JsonProperty(PropertyName = "success", Required = Required.Always)]
|
||||
public EResult Result { get; private set; }
|
||||
|
||||
@@ -208,8 +208,8 @@ public sealed class ArchiWebHandler : IDisposable {
|
||||
throw new HttpRequestException(string.Format(CultureInfo.CurrentCulture, Strings.ErrorObjectIsNull, nameof(response)));
|
||||
}
|
||||
|
||||
if (response.Content.Result != EResult.OK) {
|
||||
throw new HttpRequestException(!string.IsNullOrEmpty(response.Content.Error) ? string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.Error) : Strings.WarningFailed);
|
||||
if (response.Content.Result is not EResult.OK) {
|
||||
throw new HttpRequestException(!string.IsNullOrEmpty(response.Content.Error) ? string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.Error) : response.Content.Result.HasValue ? string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content.Result) : Strings.WarningFailed);
|
||||
}
|
||||
|
||||
if (response.Content.TotalInventoryCount == 0) {
|
||||
|
||||
Reference in New Issue
Block a user