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

Do not throw errors but report diagnostic #1508

Open
JiaqiZhang-Dev opened this issue Mar 3, 2025 · 1 comment · May be fixed by #1513
Open

Do not throw errors but report diagnostic #1508

JiaqiZhang-Dev opened this issue Mar 3, 2025 · 1 comment · May be fixed by #1513
Assignees
Labels
design-discussion An area of design currently under discussion and open to team and community feedback.
Milestone

Comments

@JiaqiZhang-Dev
Copy link
Member

JiaqiZhang-Dev commented Mar 3, 2025

Emitters should report errors as many as possible therefore if possible, emitters should not crash on purpose (for example throw new Error).

Throwing an error will cause the emitter to crash, and when the emitter crashes, typespec compiler will flag this as a bug in the emitter and recommend the user to open an issue for it.

For those unexpected, it is fine that the emitter would crash, because it is "unexpected", we could never prevent it therefore it should be categorized as a bug.

Ensure do not throw Error unless we really want the emitter to crash, otherwise we should report error diagnostic.

@JiaqiZhang-Dev JiaqiZhang-Dev self-assigned this Mar 3, 2025
@RickWinter RickWinter added the design-discussion An area of design currently under discussion and open to team and community feedback. label Mar 3, 2025
@RickWinter RickWinter added this to the 2025-04 milestone Mar 3, 2025
@RickWinter
Copy link
Member

RickWinter commented Mar 3, 2025

Per @jhendrixMSFT , Perhaps we throw a special exception which is then caught at the top level. This would be reported as an Emitter error rather than a crash. This aligns with typespec's diagnostics model approach.

Additionally, We should be able to emit code models if we complete construction of them. i.e. Don't throw during codegen...

@JiaqiZhang-Dev JiaqiZhang-Dev linked a pull request Mar 6, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-discussion An area of design currently under discussion and open to team and community feedback.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants