Skip to content
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

patch: improve error message #609

Merged
merged 3 commits into from
Feb 9, 2025
Merged

patch: improve error message #609

merged 3 commits into from
Feb 9, 2025

Conversation

ArnavK-09
Copy link
Contributor

@ArnavK-09 ArnavK-09 commented Feb 9, 2025

/claim #556

Before

image

After

image

Copy link

vercel bot commented Feb 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tscircuit-core-benchmarks ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 9, 2025 6:33pm

Copy link
Contributor

@Anshgrover23 Anshgrover23 left a comment

Choose a reason for hiding this comment

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

@ArnavK-09 can u show if this works using yalc package??

@ArnavK-09
Copy link
Contributor Author

@ArnavK-09 can u show if this works using yalc package??

@Anshgrover23

BEFORE

image

AFTER

image

@@ -466,6 +466,11 @@ export abstract class PrimitiveComponent<
}

add(component: PrimitiveComponent) {
if (!component.onAddToParent) {
throw new Error(
"Invalid JSX Element: Expected a React component but received a non-component value. Ensure you are using a valid component (function or class) and that it's properly imported.",
Copy link
Contributor

Choose a reason for hiding this comment

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

can you attempt to stringify it to make the error message even better.

Also no need for the latter half

Suggested change
"Invalid JSX Element: Expected a React component but received a non-component value. Ensure you are using a valid component (function or class) and that it's properly imported.",
"Invalid JSX Element: Expected a React component but received "...".

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

nice work, can we improve the error message?

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

JSON.stringify fails sometimes no? we don't want to accidentally throw an unrelated error (I think)

</board>,
)
}).toThrowError("Invalid JSX Element")
})
Copy link
Contributor

Choose a reason for hiding this comment

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

make sure to test with new ClassName() because i think JSON.stringify could error

Copy link
Contributor

Choose a reason for hiding this comment

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

or you could put in a function or something

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

eh it's pretty hard to break JSON.stringify

@seveibar seveibar merged commit 925be9e into tscircuit:main Feb 9, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants