Skip to content

Commit a1d3c8d

Browse files
authored
Merge pull request #31 from LootLocker/fix/NullHandling
Error handling for null-responses
2 parents 36b313e + 0b85862 commit a1d3c8d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Runtime/Client/LootLockerServerRequest.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,16 @@ public static void Serialize<T>(Action<T> onComplete, LootLockerResponse serverR
7979
}
8080

8181
public static T Serialize<T>(LootLockerResponse serverResponse)
82-
where T : LootLockerResponse
82+
where T : LootLockerResponse, new()
8383
{
84-
if (!string.IsNullOrEmpty(serverResponse.Error)) return null;
84+
if (serverResponse == null)
85+
{
86+
return new T() { success = false, Error = "Unknown error, please check your internet connection." };
87+
}
88+
else if (!string.IsNullOrEmpty(serverResponse.Error))
89+
{
90+
return new T() { success = false, Error = serverResponse.Error };
91+
}
8592

8693
var response = JsonConvert.DeserializeObject<T>(serverResponse.text);
8794

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.lootlocker.lootlockersdk",
3-
"version": "1.1.21",
3+
"version": "1.1.22",
44
"displayName": "LootLocker",
55
"description": "LootLocker SDK",
66
"unity": "2019.2",

0 commit comments

Comments
 (0)