Skip to content

Commit 8f6dfca

Browse files
committed
Error handling for null-responses
1 parent 36b313e commit 8f6dfca

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
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 = "Unkown 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

0 commit comments

Comments
 (0)