supabase-community / supabase-kt

A Kotlin Multiplatform Client for Supabase.
https://supabase.com/docs/reference/kotlin/introduction
MIT License
328 stars 33 forks source link

Add error code enum for Auth API errors #618

Closed jan-tennert closed 3 weeks ago

jan-tennert commented 3 weeks ago

What kind of change does this PR introduce?

Feature (closes #616)

What is the current behavior?

You only receive the raw error code value.

What is the new behavior?

All rest errors containing a error_code field will now throw a AuthRestException rather than generic BadRequestExceptions, etc. AuthRestExceptions contain a errorCode field of the type AuthErrorCode containing all known error codes. Two error codes have their own exceptions (but obviously inherit from AuthRestException): AuthWeakPasswordException and AuthSessionMissingException. API errors not containing this field will throw the generic exceptions.