Skip to content

Commit

Permalink
Add API docs to the top-level error types
Browse files Browse the repository at this point in the history
  • Loading branch information
jayohms committed Feb 27, 2024
1 parent b7b1e54 commit 45d543b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions turbo/src/main/kotlin/dev/hotwire/turbo/errors/HttpError.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ package dev.hotwire.turbo.errors

import android.webkit.WebResourceResponse

/**
* Errors representing HTTP status codes received from the server.
*/
sealed interface HttpError : TurboVisitError {
val statusCode: Int
val reasonPhrase: String?

/**
* Errors representing HTTP client errors in the 400..499 range.
*/
sealed interface ClientError : HttpError {
data object BadRequest : ClientError {
override val statusCode = 400
Expand Down Expand Up @@ -78,6 +84,9 @@ sealed interface HttpError : TurboVisitError {
) : ClientError
}

/**
* Errors representing HTTP server errors in the 500..599 range.
*/
sealed interface ServerError : HttpError {
data object InternalServerError : ServerError {
override val statusCode = 500
Expand Down
4 changes: 4 additions & 0 deletions turbo/src/main/kotlin/dev/hotwire/turbo/errors/LoadError.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package dev.hotwire.turbo.errors

/**
* Errors representing when turbo.js or the native adapter fails
* to load on a page.
*/
sealed interface LoadError : TurboVisitError {
val description: String

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package dev.hotwire.turbo.errors

/**
* Represents all possible errors received when attempting to load a page.
*/
sealed interface TurboVisitError
5 changes: 5 additions & 0 deletions turbo/src/main/kotlin/dev/hotwire/turbo/errors/WebError.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import androidx.webkit.WebViewClientCompat
import androidx.webkit.WebViewFeature
import androidx.webkit.WebViewFeature.isFeatureSupported

/**
* Errors representing WebViewClient.ERROR_* errors received
* from the WebView when attempting to load a page.
* https://developer.android.com/reference/android/webkit/WebViewClient
*/
sealed interface WebError : TurboVisitError {
val errorCode: Int
val description: String?
Expand Down
5 changes: 5 additions & 0 deletions turbo/src/main/kotlin/dev/hotwire/turbo/errors/WebSslError.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ package dev.hotwire.turbo.errors

import android.net.http.SslError

/**
* Errors representing SslError.SSL_* errors received
* from the WebView when attempting to load a page.
* https://developer.android.com/reference/android/net/http/SslError
*/
sealed interface WebSslError : TurboVisitError {
val errorCode: Int
val description: String?
Expand Down

0 comments on commit 45d543b

Please sign in to comment.