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

🖊️ Add user-friendly errors for calculations with incorrect types #3465 #5226

Merged
merged 5 commits into from
Mar 12, 2024

Conversation

boryanagoncharenko
Copy link
Collaborator

Fixes #3465
Add custom error message when calculations are passed incompatible types.

How to test

  • All automated tests should pass
  • Run Hedy locally and navigate to specified level. Run the following code and supply a string instead of a number. Ensure that there is a nice error displayed and no python error leaks:
    Level 6
hoeken = ask 'Hoeveel hoeken krijgt dit figuur?'
hoek = 360 / hoeken
print hoek

Level 12

hoeken = ask 'Hoeveel hoeken krijgt dit figuur?'
hoek = 360 / hoeken
print hoek

Level 12. Note that addition should show a different error since concatenation works from level 12.

hoeken = ask 'Hoeveel hoeken krijgt dit figuur?'
hoek = 360 + hoeken
print hoek

@boryanagoncharenko boryanagoncharenko force-pushed the runtime_error_messages_3465 branch 7 times, most recently from 00dac5b to ed3f4b5 Compare March 10, 2024 10:24
@jpelay jpelay self-assigned this Mar 12, 2024
Copy link
Member

@jpelay jpelay left a comment

Choose a reason for hiding this comment

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

Hi, Boryana! This works great, thank you so much :D

Copy link
Contributor

mergify bot commented Mar 12, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

Copy link
Contributor

mergify bot commented Mar 12, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit d4b27f3 into main Mar 12, 2024
12 checks passed
@mergify mergify bot deleted the runtime_error_messages_3465 branch March 12, 2024 18:26
boryanagoncharenko added a commit that referenced this pull request Mar 13, 2024
… (#5226)

Fixes #3465
Add custom error message when calculations are passed incompatible types.

**How to test**
- All automated tests should pass
- Run Hedy locally and navigate to specified level. Run the following code and supply a string instead of a number. Ensure that there is a nice error displayed and no python error leaks:
Level 6
```
hoeken = ask 'Hoeveel hoeken krijgt dit figuur?'
hoek = 360 / hoeken
print hoek
```
Level 12
```
hoeken = ask 'Hoeveel hoeken krijgt dit figuur?'
hoek = 360 / hoeken
print hoek
```
Level 12. Note that addition should show a different error since concatenation works from level 12.
```
hoeken = ask 'Hoeveel hoeken krijgt dit figuur?'
hoek = 360 + hoeken
print hoek
```
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.

[BUG] Unclear message "unsupported operand type(s) for //: 'int' and 'str'"
2 participants