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

Core: trace error to player, if possible. #2023

Merged
merged 4 commits into from
Jul 25, 2023
Merged

Conversation

Berserker66
Copy link
Member

What is this fixing or adding?

Exception: Exception in <bound method StardewValleyWorld.create_items of <worlds.stardew_valley.StardewValleyWorld object at 0x000001CB2EF3BD90>> for player 4, named Tester

How was this tested?

By crashing SDV

If this makes graphical changes, please attach screenshots.

@Berserker66
Copy link
Member Author

Not sure how to best deal with that test failure. I could copy the original error text, but that changes design just to satisfy a unittest and that's the wrong way around in my opinion.

@ThePhar ThePhar added is: enhancement Issues requesting new features or pull requests implementing new features. affects: core Issues/PRs that touch core and may need additional validation. labels Jul 24, 2023
@black-sliver
Copy link
Member

Assuming you want the outer exception be what it is (I don't think the "direct cause of ..." is easily readable), the one solution that comes to mind is to implement a custom assertRaisesRegexCause or, if it's just one instance, implement that one test by hand

try:
    self.world_setup()
except Exception ex:  # we should use a custom exception class for the step failure so this is not too wide
    self.assertEqual(str(ex), "Number of items in custom_item_pool (26) is greater than blue_chest_count (25)")
else:
    raise Exception("Expected exception")

@el-u
Copy link
Collaborator

el-u commented Jul 24, 2023

Stuff like this make you wish you could use PEP 678.

@Berserker66 Berserker66 merged commit 6a96f33 into main Jul 25, 2023
@Berserker66 Berserker66 deleted the core_trace_player_in_error branch July 25, 2023 00:18
FlySniper pushed a commit to FlySniper/Archipelago that referenced this pull request Nov 14, 2023
kl3cks7r pushed a commit to kl3cks7r/Archipelago that referenced this pull request Dec 15, 2023
Jouramie pushed a commit to Jouramie/Archipelago that referenced this pull request Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: core Issues/PRs that touch core and may need additional validation. is: enhancement Issues requesting new features or pull requests implementing new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants