diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-01-13 19:54:17 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-01-13 19:54:17 +0100 |
commit | d3f059ccdddeda951231389987e8c4582321084b (patch) | |
tree | 474e035e281ef15a2aedfb846dd79a767e66309c /src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt | |
parent | 6341705f54847552e83baa25405ff0c0ea88fe0b (diff) | |
parent | 34bd66af164d7a3ca07fd90bc3f04a5e4aaec386 (diff) | |
download | skyhanni-d3f059ccdddeda951231389987e8c4582321084b.tar.gz skyhanni-d3f059ccdddeda951231389987e8c4582321084b.tar.bz2 skyhanni-d3f059ccdddeda951231389987e8c4582321084b.zip |
Merge branch 'dev' into crimson_isle_reputation
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt | 14 |
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() } } |