aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-05-09 12:04:22 +0200
committerGitHub <noreply@github.com>2024-05-09 12:04:22 +0200
commit1275efbfd79b59661920baca0a2ae852da907d7e (patch)
treefc53a786b4000075575737680f88ffccd474495b /src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
parente0c95e803d0b5269333dae739d14067305f4baa3 (diff)
downloadskyhanni-1275efbfd79b59661920baca0a2ae852da907d7e.tar.gz
skyhanni-1275efbfd79b59661920baca0a2ae852da907d7e.tar.bz2
skyhanni-1275efbfd79b59661920baca0a2ae852da907d7e.zip
Fix: Mining Event Error Spam (#1746)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
index 46a0d7b57..bf2384373 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
@@ -65,6 +65,8 @@ object APIUtil {
try {
return parser.parse(retSrc)
} catch (e: JsonSyntaxException) {
+ val name = e.javaClass.name
+ val message = "$name: ${e.message}"
if (e.message?.contains("Use JsonReader.setLenient(true)") == true) {
println("MalformedJsonException: Use JsonReader.setLenient(true)")
println(" - getJSONResponse: '$urlString'")
@@ -78,15 +80,17 @@ object APIUtil {
}
)
}
- ErrorManager.logErrorWithData(
- e, "502 Bad Gateway",
+ ErrorManager.skyHanniError(
+ "SkyHanni Connection Error",
+ "error message" to "$message(502 Bad Gateway)",
"apiName" to apiName,
"urlString" to urlString,
"returnedData" to retSrc
)
} else {
- ErrorManager.logErrorWithData(
- e, "$apiName error",
+ ErrorManager.skyHanniError(
+ "SkyHanni Connection Error",
+ "error message" to message,
"apiName" to apiName,
"urlString" to urlString,
"returnedData" to retSrc
@@ -95,16 +99,17 @@ object APIUtil {
}
}
}
- } catch (throwable: Throwable) {
+ } catch (e: Throwable) {
if (silentError) {
- throw throwable
- } else {
- ErrorManager.logErrorWithData(
- throwable, "$apiName error for url: '$urlString'",
- "apiName" to apiName,
- "urlString" to urlString,
- )
+ throw e
}
+ val name = e.javaClass.name
+ val message = "$name: ${e.message}"
+ ErrorManager.skyHanniError(
+ "SkyHanni Connection Error",
+ "error message" to message,
+ "urlString" to urlString,
+ )
} finally {
client.close()
}