clerk / clerk-docs

The documentation content for Clerk, an authentication and user management platform.
https://clerk.com/docs
102 stars 400 forks source link

Error handling documentation doesn't match actual behavior #1167

Closed kylekz closed 3 months ago

kylekz commented 3 months ago

According to this page on the backend SDK: https://clerk.com/docs/references/backend/overview

Backend SDK functions do not throw errors when something goes wrong. Instead, they return a ClerkBackendApiResponse object, just as they would if there were no errors.

This is not the actual behavior of the SDK, which throws them due to a legacy function: https://github.com/clerk/javascript/blob/%40clerk/nextjs%405.1.5/packages/backend/src/api/request.ts#L186

Looks like returning errors as values is something that's coming soon, which is fine, but then that probably shouldn't be what the documentation says. Tying into this, @clerk/shared is a dependency of @clerk/nextjs but it doesn't get installed alongside it. To get proper typing when catching errors, installing the shared package is necessary as the nextjs package doesn't re-export ClerkAPIResponseError.