warn if update check is unavailable du to client error

"no network available"
This commit is contained in:
Moritz Zwerger 2023-12-21 15:38:25 +01:00
parent e54623021f
commit 8e2bb9fc98
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 12 additions and 2 deletions

View File

@ -86,7 +86,7 @@ object Eros {
start()
}
}
MinosoftUpdater::update.observe(this) {
MinosoftUpdater::update.observe(this, true) {
if (it == null) return@observe
if (it.id == OtherProfileManager.selected.updater.dismiss) return@observe // TODO: if not searched manually
UpdateAvailableDialog(it).show()

View File

@ -20,8 +20,12 @@ import de.bixilon.kutil.url.URLUtil.toURL
import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
import de.bixilon.minosoft.properties.MinosoftProperties
import de.bixilon.minosoft.util.http.HTTP2.get
import de.bixilon.minosoft.util.http.HTTPResponse
import de.bixilon.minosoft.util.http.exceptions.HTTPException
import de.bixilon.minosoft.util.json.Jackson
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
import java.net.URL
object MinosoftUpdater {
@ -68,7 +72,13 @@ object MinosoftUpdater {
}
private fun request(url: String): MinosoftUpdate? {
val response = url.get({ it })
val response: HTTPResponse<String>
try {
response = url.get({ it })
} catch (error: Throwable) {
Log.log(LogMessageType.OTHER, LogLevels.WARN) { "Could not check for updates: $error" }
return null
}
return when (response.statusCode) {
204 -> null