Skip to content

feat(clerk-js,shared,types): Add ClerkRuntimeError class#1813

Merged
panteliselef merged 1 commit intomainfrom
ORG-194
Oct 4, 2023
Merged

feat(clerk-js,shared,types): Add ClerkRuntimeError class#1813
panteliselef merged 1 commit intomainfrom
ORG-194

Conversation

@panteliselef
Copy link
Copy Markdown
Contributor

@panteliselef panteliselef commented Oct 2, 2023

Description

With the introduction of ClerkRuntimeError class, we can localize error messages and display them in ClerkJS components. This functionality existed for FAPI errors, and we are now adding support for runtime errors.

Example

Displays an error message caused when lazy loading a 3rd party library. In this case, the sign up process cannot continue and we need to provided the end user with some feedback.
Screenshot 2023-10-02 at 2 12 53 PM

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • @clerk/chrome-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

@panteliselef panteliselef requested a review from a team as a code owner October 2, 2023 11:33
@panteliselef panteliselef self-assigned this Oct 2, 2023
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Oct 2, 2023

🦋 Changeset detected

Latest commit: 00228d4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@clerk/localizations Patch
@clerk/clerk-js Patch
@clerk/shared Patch
@clerk/types Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/fastify Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/backend Patch
gatsby-plugin-clerk Patch
@clerk/nextjs Patch
@clerk/clerk-sdk-node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

};
}

export class ClerkRuntimeError extends Error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we are adding new exports here, can we add JSDoc comments above isClerkRuntimeError and ClerkRuntimeError briefly explaining intended usage?

Copy link
Copy Markdown
Contributor

@dimkl dimkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Instead of introducing a new error class, couldn't we add the code to our existing error classes (if exists) and use a helper isTranslatableError(error) that will check if the code exists in the supported localization keys to translate the error?
I left some questions in the PR but i will approve this since I may be missing some context.

Comment thread packages/shared/src/errors/Error.ts
Comment thread packages/shared/src/errors/Error.ts Outdated
With the introduction of this class, we can localize error messages and display them in ClerkJS components. This functionality existed for FAPI errors, and we are now adding support for runtime errors.
@panteliselef panteliselef enabled auto-merge October 4, 2023 12:31
@panteliselef panteliselef added this pull request to the merge queue Oct 4, 2023
Merged via the queue into main with commit 164f3aa Oct 4, 2023
@panteliselef panteliselef deleted the ORG-194 branch October 4, 2023 12:49
@clerk-cookie clerk-cookie mentioned this pull request Oct 4, 2023
@clerk-cookie
Copy link
Copy Markdown
Collaborator

This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@clerk clerk locked as resolved and limited conversation to collaborators Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants