From 10caf09d47bab8b10f69681be13ae4381befaad1 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 19 Jun 2026 21:37:04 +0000 Subject: [PATCH] fix: add descriptive message to media download HTTP check When saving media to the gallery, a non-2xx response triggered a bare check(response.isSuccessful), which threw IllegalStateException("Check failed.") with no context. The error was caught and logged, but the message was useless for diagnosing failures and produced a generic toast. Include the URL, HTTP status code, and status message in the check so the log and downstream error handling explain why the download failed. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Cwv4DpPLTyiJP2Thv3H3jR --- .../com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt index 125677c0c3..a341fd5a8e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt @@ -109,7 +109,9 @@ object MediaSaverToDisk { client.newCall(request).executeAsync().use { response -> withContext(Dispatchers.IO) { - check(response.isSuccessful) + check(response.isSuccessful) { + "Failed to download $url: HTTP ${response.code} ${response.message}" + } val trimmedUrl = trimInlineMetaData(url) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {