aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt9
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,
)