docs: Remove error codes section from Flutter, Swift, and Python reference docs. (#28334)

* exclude dart, python, and swift from error codes menu

* Update the error code doc to be client lib agnostic

* run formatter

* Add a filter to filter out section items

* Update apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx

* docs: move error codes table in a separate component

* Add auth error codes section for kotlin
This commit is contained in:
Tyler authored and GitHub committed 2024-08-06 11:41:10 +09:00
1 parent 55acb7214f
commit eb9f0240cb
8 files changed
+52 -26

No files matched your search

@@ -1,14 +1,3 @@
Supabase Auth can throw or return various errors when using the API. All errors originating from the `supabase.auth` namespace of the JavaScript client library will be wrapped by the `AuthError` class.
Error objects are split in a few classes:
- `AuthApiError` -- errors which originate from the Supabase Auth API.
- Use `isAuthApiError` instead of `instanceof` checks to see if an error you caught is of this type.
- `CustomAuthError` -- errors which generally originate from state in the client library.
- Use the `name` property on the error to identify the class of error received.
Errors originating from the server API classed as `AuthApiError` always have a `code` property that can be used to identify the error returned by the server. The `status` property is also present, encoding the HTTP status code received in the response.
In general the HTTP status codes you will likely receive are:
- [403 Forbidden](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403) is sent out in rare situations where a certain Auth feature is not available for the user, and you as the developer are not checking a precondition whether that API is available for the user.
@@ -77,7 +66,7 @@ To supplement HTTP status codes, Supabase Auth returns a string error code which
| `sso_domain_already_exists` | (Admin API.) Only one SSO domain can be registered per SSO identity provider. |
| `sso_provider_not_found` | SSO provider not found. Check the arguments in `supabase.auth.signInWithSSO()`. |
| `too_many_enrolled_mfa_factors` | A user can only have a fixed number of enrolled MFA factors. |
| `unexpected_audience` | (Deprecated feature not available via Supabase JavaScript client.) The request's `X-JWT-AUD` claim does not match the JWT's audience. |
| `unexpected_audience` | (Deprecated feature not available via Supabase client libraries.) The request's `X-JWT-AUD` claim does not match the JWT's audience. |
| `unexpected_failure` | Auth service is degraded or a bug is present, without a specific reason. |
| `user_already_exists` | User with this information (email address, phone number) cannot be created again as it already exists. |
| `user_banned` | User to which the API request relates has a `banned_until` property which is still active. No further API requests should be attempted until this field is cleared. |
@@ -85,8 +74,3 @@ To supplement HTTP status codes, Supabase Auth returns a string error code which
| `user_sso_managed` | When a user comes from SSO, certain fields of the user cannot be updated (like `email`). |
| `validation_failed` | Provided parameters are not in the expected format. |
| `weak_password` | User is signing up or changing their password without meeting the password strength criteria. Use the `AuthWeakPasswordError` class to access more information about what they need to do to make the password pass. |
### Tips for better error handling
- Do not use string matching on error messages! Always use the `name` and `code` properties of error objects to identify the situation.
- Although HTTP status codes generally don't change, they can suddenly change due to bugs, so avoid relying on them unless absolutely necessary.
@@ -28,6 +28,12 @@ const NavigationMenuRefList = ({
}
const filteredSections = commonSections.filter((section) => {
if (section.type === 'category') {
section.items = section.items.filter((item) => {
return !item.excludes?.includes(id)
})
}
return !section.excludes?.includes(id)
})
+2
View File
@@ -35,6 +35,7 @@ import { SharedData } from './SharedData'
// Partials
import HuggingFaceDeployment from './MDX/ai/quickstart_hf_deployment.mdx'
import AuthErrorCodesTable from './MDX/auth_error_codes_table.mdx'
import AuthRateLimits from './MDX/auth_rate_limits.mdx'
import DatabaseSetup from './MDX/database_setup.mdx'
import GetSessionWarning from './MDX/get_session_warning.mdx'
@@ -90,6 +91,7 @@ const components = {
),
AppleSecretGenerator,
AuthProviders,
AuthErrorCodesTable,
AuthRateLimits,
AuthSmsProviderConfig,
Button,
@@ -53,9 +53,6 @@ export interface ICommonCategory extends ICommonBase {
export interface ICommonMarkdown extends ICommonBaseSection {
type: 'markdown'
meta?: {
shared?: boolean
}
}
export interface ICommonFunctionGroup extends ICommonBaseSection {
@@ -0,0 +1,17 @@
Supabase Auth can throw or return various errors when using the API. All errors originating from the `supabase.auth` namespace of the client library will be wrapped by the `AuthError` class.
Error objects are split in a few classes:
- `AuthApiError` -- errors which originate from the Supabase Auth API.
- Use `isAuthApiError` instead of `instanceof` checks to see if an error you caught is of this type.
- `CustomAuthError` -- errors which generally originate from state in the client library.
- Use the `name` property on the error to identify the class of error received.
Errors originating from the server API classed as `AuthApiError` always have a `code` property that can be used to identify the error returned by the server. The `status` property is also present, encoding the HTTP status code received in the response.
<AuthErrorCodesTable />
### Tips for better error handling
- Do not use string matching on error messages! Always use the `name` and `code` properties of error objects to identify the situation.
- Although HTTP status codes generally don't change, they can suddenly change due to bugs, so avoid relying on them unless absolutely necessary.
@@ -0,0 +1,17 @@
Supabase Auth can throw or return various errors when using the API. All errors originating from the `supabase.auth` namespace of the JavaScript client library will be wrapped by the `AuthError` class.
Error objects are split in a few classes:
- `AuthApiError` -- errors which originate from the Supabase Auth API.
- Use `isAuthApiError` instead of `instanceof` checks to see if an error you caught is of this type.
- `CustomAuthError` -- errors which generally originate from state in the client library.
- Use the `name` property on the error to identify the class of error received.
Errors originating from the server API classed as `AuthApiError` always have a `code` property that can be used to identify the error returned by the server. The `status` property is also present, encoding the HTTP status code received in the response.
<AuthErrorCodesTable />
### Tips for better error handling
- Do not use string matching on error messages! Always use the `name` and `code` properties of error objects to identify the situation.
- Although HTTP status codes generally don't change, they can suddenly change due to bugs, so avoid relying on them unless absolutely necessary.
+1 -2
View File
@@ -17,8 +17,7 @@ async function generateRefMarkdown(sections: ICommonMarkdown[], slug: string) {
*/
await Promise.all(
sections.map(async (section) => {
const isSharedSection = section.meta?.shared
const pathName = `docs/ref${isSharedSection ? '/shared' : slug}/${section.id}.mdx`
const pathName = `docs/ref${slug}/${section.id}.mdx`
function checkFileExists(x) {
if (fs.existsSync(x)) {
@@ -404,9 +404,13 @@
"title": "Error codes",
"slug": "auth-error-codes",
"type": "markdown",
"meta": {
"shared": true
}
"excludes": [
"reference_dart_v1",
"reference_dart_v2",
"reference_python_v2",
"reference_swift_v1",
"reference_swift_v2"
]
},
{
"id": "sign-up",
@@ -1012,4 +1016,4 @@
}
]
}
]
]