Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element Call: display error dialog only when loading the main URL #3962

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,34 @@ class WebViewWidgetMessageInterceptor(
override fun onReceivedError(view: WebView?, request: WebResourceRequest?, error: WebResourceError?) {
// No network for instance, transmit the error
Timber.e("onReceivedError error: ${error?.errorCode} ${error?.description}")
onError(error?.description?.toString())

// Only propagate the error if it happens while loading the current page
if (view?.url == request?.url.toString()) {
onError(error?.description.toString())
}

super.onReceivedError(view, request, error)
}

override fun onReceivedHttpError(view: WebView?, request: WebResourceRequest?, errorResponse: WebResourceResponse?) {
Timber.e("onReceivedHttpError error: ${errorResponse?.statusCode} ${errorResponse?.reasonPhrase}")
onError(errorResponse?.statusCode.toString())

// Only propagate the error if it happens while loading the current page
if (view?.url == request?.url.toString()) {
onError(errorResponse?.statusCode.toString())
}

super.onReceivedHttpError(view, request, errorResponse)
}

override fun onReceivedSslError(view: WebView?, handler: SslErrorHandler?, error: SslError?) {
Timber.e("onReceivedSslError error: ${error?.primaryError}")
onError(error?.primaryError?.toString())

// Only propagate the error if it happens while loading the current page
if (view?.url == error?.url.toString()) {
onError(error?.toString())
}

super.onReceivedSslError(view, handler, error)
}
}
Expand Down