Skip to content

Commit 018771e

Browse files
committed
Consolidate the error handling
1 parent 79ddfaf commit 018771e

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3995,9 +3995,13 @@ class BrowserTabFragment :
39953995
).findViewById<DuckDuckGoWebView>(R.id.browserWebView)
39963996

39973997
webView?.let {
3998-
if (webViewModeInitializer.bind(it, browserMode).isFailure) {
3998+
val bindResult = webViewModeInitializer.bind(it, browserMode)
3999+
if (bindResult.isFailure) {
39994000
if (browserMode != BrowserMode.REGULAR) {
4000-
logcat(ERROR) { "Attempting to open a FIRE tab while Fire mode is unsupported." }
4001+
bindResult.exceptionOrNull()?.message?.let {
4002+
message ->
4003+
logcat(ERROR) { message }
4004+
}
40014005
this.closeCurrentTab()
40024006
return
40034007
}

browser-mode/browser-mode-impl/src/main/java/com/duckduckgo/browsermode/impl/RealWebViewModeInitializer.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import android.annotation.SuppressLint
2020
import android.webkit.WebView
2121
import androidx.webkit.ProfileStore
2222
import androidx.webkit.WebViewCompat
23+
import androidx.webkit.WebViewFeature
2324
import com.duckduckgo.browsermode.api.BrowserMode
24-
import com.duckduckgo.browsermode.api.FireModeAvailability
2525
import com.duckduckgo.browsermode.api.WebViewModeInitializer
2626
import com.duckduckgo.browsermode.api.profileName
2727
import com.duckduckgo.di.scopes.AppScope
@@ -32,15 +32,14 @@ import javax.inject.Inject
3232
@SingleInstanceIn(AppScope::class)
3333
@ContributesBinding(AppScope::class)
3434
class RealWebViewModeInitializer @Inject constructor(
35-
private val fireModeAvailability: FireModeAvailability,
3635
private val webViewProfileBinder: WebViewProfileBinder,
3736
) : WebViewModeInitializer {
3837
override fun bind(webView: WebView, mode: BrowserMode): Result<Unit> {
39-
if (!fireModeAvailability.isAvailable()) {
38+
if (!WebViewFeature.isFeatureSupported(WebViewFeature.MULTI_PROFILE)) {
4039
return Result.failure(
4140
IllegalStateException(
4241
"Attempting to bind a WebView profile to " +
43-
"Fire mode when the Fire mode feature is not available.",
42+
"{${mode.name}} mode when MULTI_PROFILE feature is not available.",
4443
),
4544
)
4645
}

0 commit comments

Comments
 (0)