Skip to content

Commit

Permalink
Consider SocketException as network error (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
poovamraj authored May 18, 2023
1 parent b2c5f66 commit 4d7ebbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.auth0.android.NetworkErrorException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import com.auth0.android.provider.TokenValidationException
import java.net.SocketException

public class AuthenticationException : Auth0Exception {
private var code: String? = null
Expand Down Expand Up @@ -108,6 +109,7 @@ public class AuthenticationException : Auth0Exception {
get() = cause is NetworkErrorException
|| cause?.cause is UnknownHostException
|| cause?.cause is SocketTimeoutException
|| cause?.cause is SocketException

// When there is no Browser app installed to handle the web authentication
public val isBrowserAppNotAvailable: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import java.io.FileReader
import java.io.IOException
import java.net.SocketException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import java.util.*
Expand Down Expand Up @@ -221,6 +222,16 @@ public class AuthenticationExceptionTest {
MatcherAssert.assertThat(ex.isNetworkError, CoreMatchers.`is`(true))
}

@Test
public fun shouldHaveNetworkErrorForSocketException() {
val ex = AuthenticationException(
"Request has definitely failed", NetworkErrorException(
SocketException()
)
)
MatcherAssert.assertThat(ex.isNetworkError, CoreMatchers.`is`(true))
}

@Test
public fun shouldHaveRequestVerificationError() {
values[CODE_KEY] = "requires_verification"
Expand Down

0 comments on commit 4d7ebbb

Please sign in to comment.