Kipper
Kipper copied to clipboard
[Feature] Implement `throw` keyword to raise errors inside any code block
Is there an existing proposal for this?
- [X] I have searched the existing issues
This feature does not exist in the latest version
- [X] 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
andTypeScript
.