Skip to content

Commit

Permalink
add some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-tennert committed Jun 25, 2024
1 parent 9421a30 commit bcff7c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit bcff7c1

Please sign in to comment.