-
Notifications
You must be signed in to change notification settings - Fork 406
fix(shared): Rename static properties from 'name' to 'kind' in error classes #7004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@clerk/shared": patch | ||
| --- | ||
|
|
||
| Rename static properties from 'name' to 'kind' in ClerkError class | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ export interface ClerkErrorParams { | |
| const __DEV__ = true; | ||
|
|
||
| export class ClerkError extends Error { | ||
| static name = 'ClerkError'; | ||
| static kind = 'ClerkError'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Add TypeScript constraint for subclass static While the static Consider adding an abstract static accessor or documenting the requirement: export class ClerkError extends Error {
static kind = 'ClerkError';
+ // Subclasses must define their own static kind property
readonly clerkError = true as const;Alternatively, provide a runtime check in the constructor: constructor(opts: ClerkErrorParams) {
const kind = (this.constructor as typeof ClerkError).kind;
if (!kind) {
throw new Error(`${this.constructor.name} must define a static 'kind' property`);
}
super(new.target.formatMessage(kind, opts.message, opts.code, opts.docsUrl), { cause: opts.cause });
// ...
}🤖 Prompt for AI Agents |
||
| readonly clerkError = true as const; | ||
| readonly code: string; | ||
| readonly longMessage: string | undefined; | ||
|
|
@@ -46,7 +46,7 @@ export class ClerkError extends Error { | |
| } | ||
|
|
||
| constructor(opts: ClerkErrorParams) { | ||
| super(new.target.formatMessage(new.target.name, opts.message, opts.code, opts.docsUrl), { cause: opts.cause }); | ||
| super(new.target.formatMessage(new.target.kind, opts.message, opts.code, opts.docsUrl), { cause: opts.cause }); | ||
nikosdouvlis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Object.setPrototypeOf(this, ClerkError.prototype); | ||
| this.code = opts.code; | ||
| this.docsUrl = opts.docsUrl; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify scope of the change.
The rename applies to multiple error classes/utilities, not just
ClerkError. Please update the note so downstream readers understand the broader impact.🧰 Tools
🪛 LanguageTool
[grammar] ~5-~5: There might be a mistake here.
Context: ...static properties from 'name' to 'kind' in ClerkError class
(QB_NEW_EN)
🤖 Prompt for AI Agents