hotwired / turbo-android

Android framework for making Turbo native apps
MIT License
408 stars 51 forks source link

onReceivedError is overloaded #242

Closed svantepolk closed 4 months ago

svantepolk commented 1 year ago

Turbo has made a choice to funnel all errors into one callback and one datapoint, despite the datatype referring to 3 different things like it's a C union. It could be an HTTP status, a WebViewClient error code, or Turbo's JS error.

Splitting out the HTTP status codes isn't too difficult by looking at numbers over 299, but in the case of the latter, it actually collides with an existing WebViewClient error code. This makes it difficult to figure out whether the 'turbo didn't load' error actually occurred, or if some other "Generic error" occurred.

https://github.com/hotwired/turbo-android/blob/8e753ef9a2660ddf02f970e1278c7d7f866e5e1c/turbo/src/main/kotlin/dev/hotwire/turbo/session/TurboSession.kt#L458 https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNKNOWN

jayohms commented 4 months ago

There's now a comprehensive solution in #317 with custom error types.