From 11c9f7515a2805f06057fd49330de13fdbf04369 Mon Sep 17 00:00:00 2001 From: Tuomas Airaksinen Date: Sat, 14 Dec 2024 19:18:59 +0200 Subject: [PATCH] Improve code a bit --- .../sword/SwordEnvironmentInitialisation.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/net/bible/service/sword/SwordEnvironmentInitialisation.kt b/app/src/main/java/net/bible/service/sword/SwordEnvironmentInitialisation.kt index e1def38ff6..7eee75b2a2 100644 --- a/app/src/main/java/net/bible/service/sword/SwordEnvironmentInitialisation.kt +++ b/app/src/main/java/net/bible/service/sword/SwordEnvironmentInitialisation.kt @@ -111,14 +111,12 @@ object SwordEnvironmentInitialisation { } private fun showMsg(ev: ReporterEvent?) { - val msg = if (ev == null) { - getResourceString(R.string.error_occurred) - } else if (!StringUtils.isEmpty(ev.message)) { - ev.message - } else if (ev.exception != null && !StringUtils.isEmpty(ev.exception.message)) { - getResourceString(R.string.error_occurred_with_link, ev.exception.message!!) - } else { - getResourceString(R.string.error_occurred) + val msg = when { + ev == null -> getResourceString(R.string.error_occurred) + !StringUtils.isEmpty(ev.message) -> ev.message + ev.exception != null && !StringUtils.isEmpty(ev.exception.message) -> + getResourceString(R.string.error_occurred_with_link, ev.exception.message!!) + else -> getResourceString(R.string.error_occurred) } // convert Throwable to Exception for Dialogs val e: Exception = if (ev != null) {