diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-09 12:04:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 12:04:22 +0200 |
commit | 1275efbfd79b59661920baca0a2ae852da907d7e (patch) | |
tree | fc53a786b4000075575737680f88ffccd474495b /src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt | |
parent | e0c95e803d0b5269333dae739d14067305f4baa3 (diff) | |
download | skyhanni-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.kt | 29 |
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() } |