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

[Feature] Implement throw keyword to raise errors inside any code block #687

Open
2 tasks done
Luna-Klatzer opened this issue Jul 25, 2024 · 0 comments
Open
2 tasks done
Assignees
Labels
feature New feature or enhancement
Milestone

Comments

@Luna-Klatzer
Copy link
Member

Is there an existing proposal for this?

  • I have searched the existing issues

This feature does not exist in the latest version

  • I am using the latest version

Proposal

Implement throw keyword which should allow throwing any object of type Error.

For example:

throw new Error("An unexpected Error occurred");

The thrown error should then be catchable using the try/except statement as mentioned in #654:

try {
  ...
  throw new Error();
} except (e: Error) {
  print(f"Something happened! Cause: {e}");
}

Exact behaviour / changes you want

  • Implement new keyword and operator throw.
  • Add semantic checks and ensure that the thrown expression is always of type Error.
  • Add target code generation for JavaScript and TypeScript.
@Luna-Klatzer Luna-Klatzer added the feature New feature or enhancement label Jul 25, 2024
@Luna-Klatzer Luna-Klatzer added this to the v0.12.0 milestone Jul 25, 2024
@Luna-Klatzer Luna-Klatzer self-assigned this Jul 25, 2024
@Luna-Klatzer Luna-Klatzer linked a pull request Sep 2, 2024 that will close this issue
8 tasks
@Luna-Klatzer Luna-Klatzer modified the milestones: v0.12.0, v0.13.0 Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or enhancement
Projects
Development

No branches or pull requests

2 participants