diff --git a/GoTrue/src/commonMain/kotlin/io/github/jan/supabase/gotrue/AuthImpl.kt b/GoTrue/src/commonMain/kotlin/io/github/jan/supabase/gotrue/AuthImpl.kt index 8dbbf04a..faec18d1 100644 --- a/GoTrue/src/commonMain/kotlin/io/github/jan/supabase/gotrue/AuthImpl.kt +++ b/GoTrue/src/commonMain/kotlin/io/github/jan/supabase/gotrue/AuthImpl.kt @@ -277,7 +277,7 @@ internal class AuthImpl( parameter("scope", scope.name.lowercase()) } } catch(e: RestException) { - val errorCode = if(e is AuthRestException) e.statusCode else if(e is UnknownRestException) e.errorCode else -1 + val errorCode = if(e is AuthRestException) e.statusCode else if(e is UnknownRestException) e.statusCode else -1 if(errorCode in listOf(401, 403, 404)) { Auth.logger.d { "Received error code $errorCode while signing out user. This can happen if the user doesn't exist anymore or the JWT is invalid/expired. Proceeding to clean up local data..." } } else throw e @@ -492,7 +492,7 @@ internal class AuthImpl( response, errorBody.description ) - else -> UnknownRestException(errorBody.error ?: "Unknown Error", response, errorCode = response.status.value) + else -> UnknownRestException(errorBody.error ?: "Unknown Error", response, statusCode = response.status.value) } } diff --git a/GoTrue/src/commonMain/kotlin/io/github/jan/supabase/gotrue/exception/AuthRestException.kt b/GoTrue/src/commonMain/kotlin/io/github/jan/supabase/gotrue/exception/AuthRestException.kt index 0127d007..88bf9428 100644 --- a/GoTrue/src/commonMain/kotlin/io/github/jan/supabase/gotrue/exception/AuthRestException.kt +++ b/GoTrue/src/commonMain/kotlin/io/github/jan/supabase/gotrue/exception/AuthRestException.kt @@ -5,6 +5,7 @@ import io.github.jan.supabase.exceptions.RestException /** * Base class for rest exceptions thrown by the Auth API. * @property errorCode The error code of the rest exception. This should be a known [AuthErrorCode]. If it is not, use [error] instead. + * @property statusCode The HTTP status code of the rest exception. * @param message The message of the rest exception. */ open class AuthRestException(errorCode: String, message: String, val statusCode: Int = -1): RestException( diff --git a/src/commonMain/kotlin/io/github/jan/supabase/exceptions/RestException.kt b/src/commonMain/kotlin/io/github/jan/supabase/exceptions/RestException.kt index 55739541..836cbcb8 100644 --- a/src/commonMain/kotlin/io/github/jan/supabase/exceptions/RestException.kt +++ b/src/commonMain/kotlin/io/github/jan/supabase/exceptions/RestException.kt @@ -42,5 +42,6 @@ class NotFoundRestException(error: String, response: HttpResponse, message: Stri /** * Thrown for all other response codes + * @property statusCode The HTTP status code */ -class UnknownRestException(error: String, response: HttpResponse, message: String? = null, val errorCode: Int = -1): RestException(error, response, message) +class UnknownRestException(error: String, response: HttpResponse, message: String? = null, val statusCode: Int = -1): RestException(error, response, message)