From f91ec749011d318af0b823535daed4aef890db5f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:53:19 +0100 Subject: Better explanation for the bazaar api error. --- src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt index 908d8b810..d776cfa01 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod import com.google.gson.JsonObject import com.google.gson.JsonParser -import com.google.gson.stream.MalformedJsonException +import com.google.gson.JsonSyntaxException import org.apache.http.client.config.RequestConfig import org.apache.http.client.methods.HttpGet import org.apache.http.impl.client.HttpClientBuilder @@ -43,9 +43,15 @@ object APIUtil { val retSrc = EntityUtils.toString(entity) try { return parser.parse(retSrc) as JsonObject - } catch (e: MalformedJsonException) { - LorenzUtils.error("MalformedJsonException!") - println("MalformedJsonException at '$urlString'") + } catch (e: JsonSyntaxException) { + if (retSrc.contains("

502 Bad Gateway

")) { + println("502 Bad Gateway at getJSONResponse '$urlString'") + LorenzUtils.error("[SkyHanni] Hypixel API error: 502 Bad Gateway!") + } else { + println("JsonSyntaxException at getJSONResponse '$urlString'") + LorenzUtils.error("[SkyHanni] JsonSyntaxException at getJSONResponse!") + println("result: '$retSrc'") + } e.printStackTrace() } } -- cgit