From 7c9aab5e63c37d476155074c89065b7a8deb53ed Mon Sep 17 00:00:00 2001 From: yairm210 Date: Sun, 28 Jul 2024 14:07:12 +0300 Subject: [PATCH] Show text for json parse errors from github search --- core/src/com/unciv/logic/github/Github.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/github/Github.kt b/core/src/com/unciv/logic/github/Github.kt index f82da160c9..826c2f1c2a 100644 --- a/core/src/com/unciv/logic/github/Github.kt +++ b/core/src/com/unciv/logic/github/Github.kt @@ -212,7 +212,12 @@ object Github { retries++ // An extra retry so the 403 is ignored in the retry count } } ?: continue - return json().fromJson(GithubAPI.RepoSearch::class.java, inputStream.bufferedReader().readText()) + val text = inputStream.bufferedReader().readText() + try { + return json().fromJson(GithubAPI.RepoSearch::class.java, text) + } catch (_: Throwable) { + throw Exception("Failed to parse Github response as json - $text") + } } return null }