Skip to content

Commit 0c6d236

Browse files
committed
Renamed server error to api error to indicate general api error types
1 parent 9395de6 commit 0c6d236

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
329329
error.isRefreshTokenDeleted ||
330330
error.isInvalidRefreshToken -> CredentialsManagerException.Code.RENEW_FAILED
331331
error.isNetworkError -> CredentialsManagerException.Code.NO_NETWORK
332-
else -> CredentialsManagerException.Code.SERVER_ERROR
332+
else -> CredentialsManagerException.Code.API_ERROR
333333
}
334334
callback.onFailure(
335335
CredentialsManagerException(

auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManagerException.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class CredentialsManagerException :
4444
BIOMETRICS_INVALID_USER,
4545
BIOMETRIC_AUTHENTICATION_FAILED,
4646
NO_NETWORK,
47-
SERVER_ERROR
47+
API_ERROR
4848
}
4949

5050
private var code: Code?
@@ -140,8 +140,8 @@ public class CredentialsManagerException :
140140
//Exceptions thrown when making api calls for access token renewal
141141
public val NO_NETWORK: CredentialsManagerException =
142142
CredentialsManagerException(Code.NO_NETWORK)
143-
public val SERVER_ERROR: CredentialsManagerException =
144-
CredentialsManagerException(Code.SERVER_ERROR)
143+
public val API_ERROR: CredentialsManagerException =
144+
CredentialsManagerException(Code.API_ERROR)
145145

146146

147147
private fun getMessage(code: Code): String {
@@ -186,7 +186,7 @@ public class CredentialsManagerException :
186186
Code.BIOMETRICS_INVALID_USER -> "The user didn't pass the authentication challenge."
187187
Code.BIOMETRIC_AUTHENTICATION_FAILED -> "Biometric authentication failed."
188188
Code.NO_NETWORK -> "Failed to execute the network request."
189-
Code.SERVER_ERROR -> "An error occurred when trying to authenticate with the server."
189+
Code.API_ERROR -> "An error occurred while processing the request."
190190
}
191191
}
192192
}

auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
590590
error.isRefreshTokenDeleted ||
591591
error.isInvalidRefreshToken -> CredentialsManagerException.Code.RENEW_FAILED
592592
error.isNetworkError -> CredentialsManagerException.Code.NO_NETWORK
593-
else -> CredentialsManagerException.Code.SERVER_ERROR
593+
else -> CredentialsManagerException.Code.API_ERROR
594594
}
595595
callback.onFailure(
596596
CredentialsManagerException(

auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ public class CredentialsManagerTest {
916916
}
917917

918918
@Test
919-
public fun shouldGetAndFailToRenewExpiredCredentialsWhenServerErrorOccurs() {
919+
public fun shouldGetAndFailToRenewExpiredCredentialsWhenApiErrorOccurs() {
920920
Mockito.`when`(storage.retrieveString("com.auth0.id_token")).thenReturn("idToken")
921921
Mockito.`when`(storage.retrieveString("com.auth0.access_token")).thenReturn("accessToken")
922922
Mockito.`when`(storage.retrieveString("com.auth0.refresh_token")).thenReturn("refreshToken")
@@ -950,7 +950,7 @@ public class CredentialsManagerTest {
950950
MatcherAssert.assertThat(exception.cause, Is.`is`(authenticationException))
951951
MatcherAssert.assertThat(
952952
exception.message,
953-
Is.`is`("An error occurred when trying to authenticate with the server.")
953+
Is.`is`("An error occurred while processing the request.")
954954
)
955955
}
956956

auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ public class SecureCredentialsManagerTest {
13751375
}
13761376

13771377
@Test
1378-
public fun shouldGetAndFailToRenewExpiredCredentialsWhenServerErrorOccurs() {
1378+
public fun shouldGetAndFailToRenewExpiredCredentialsWhenApiErrorOccurs() {
13791379
Mockito.`when`(localAuthenticationManager.authenticate()).then {
13801380
localAuthenticationManager.resultCallback.onSuccess(true)
13811381
}
@@ -1406,7 +1406,7 @@ public class SecureCredentialsManagerTest {
14061406
MatcherAssert.assertThat(exception.cause, Is.`is`(authenticationException))
14071407
MatcherAssert.assertThat(
14081408
exception.message,
1409-
Is.`is`("An error occurred when trying to authenticate with the server.")
1409+
Is.`is`("An error occurred while processing the request.")
14101410
)
14111411
}
14121412

0 commit comments

Comments
 (0)