google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.43k stars 598 forks source link

[WebView] Does not report HTTP errors #1448

Closed danielesegato closed 1 year ago

danielesegato commented 1 year ago

Description When loading a web page the state.errorsForCurrentRequest does not report HTTP errors with the page being loaded (ex. a 404 or a 403).

Steps to reproduce

@Composable
fun ReproduceError() {
  val state = rememberWebViewState("https://www.google.com/404") // or any url returning an HTTP error
  WebView(
    state = state,
    modifier = Modifier
        .fillMaxSize(),
  )
  println("${
                state.errorsForCurrentRequest
                    .joinToString(separator = "\n") { "[${it.error.errorCode}] ${it.error.description}" }
            }")
}

nothing will be print, no error despite the page having a 404

Expected behavior http errors of the main page should be reported somehow by the state

Additional context It is relatively easy to "fix" by extending AccompanistWebViewClient with your own state for the error which is provided by the onReceivedHttpError() method.

but I think it should be part of the errors exposed by default by the library.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

danielesegato commented 1 year ago

Was coming to ask if you had a chance to check this out, and I see you removed the stale label already! Thank you :-)

bentrengrove commented 1 year ago

Yes sorry! I will implement this, I just haven't had a chance yet

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

danielesegato commented 1 year ago

I guess there's no plan to do this?