aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt14
1 files changed, 10 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 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("<center><h1>502 Bad Gateway</h1></center>")) {
+ 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()
}
}