diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-02-16 17:55:33 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 07:55:33 +0100 |
commit | 70bbbc3c2002c55866db74d8121e94ef848c5cfd (patch) | |
tree | 597d217b52d888ee2e49641f9dc9cbc08a8e230f /src/main/java/at/hannibal2/skyhanni/utils | |
parent | a1c5df9b65a75d6833bf2aaa23e6f9b86f5a7a1c (diff) | |
download | skyhanni-70bbbc3c2002c55866db74d8121e94ef848c5cfd.tar.gz skyhanni-70bbbc3c2002c55866db74d8121e94ef848c5cfd.tar.bz2 skyhanni-70bbbc3c2002c55866db74d8121e94ef848c5cfd.zip |
Fixed rare farming weight API errors. #1014
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt index 0f561fdff..33da6ed38 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt @@ -116,7 +116,6 @@ object APIUtil { } val message = "POST request to '$urlString' returned status ${status.statusCode}" - println(message) ChatUtils.error("SkyHanni ran into an error. Status: ${status.statusCode}") return ApiResponse(false, message, JsonObject()) } @@ -134,8 +133,10 @@ object APIUtil { } private fun readResponse(entity: HttpEntity): JsonObject { - val retSrc = EntityUtils.toString(entity) - return parser.parse(retSrc) as JsonObject + val retSrc = EntityUtils.toString(entity) ?: return JsonObject() + val parsed = parser.parse(retSrc) + if (parsed.isJsonNull) return JsonObject() + return parsed as JsonObject } fun postJSONIsSuccessful(url: String, body: String, silentError: Boolean = false): Boolean { @@ -145,12 +146,12 @@ object APIUtil { return true } - println(response.message) ErrorManager.logErrorStateWithData( "An error occurred during the API request", "unsuccessful API response", "url" to url, "body" to body, + "message" to response.message, "response" to response, ) |