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

fix: if only single compiler error, avoid wrapping in a new error #2251

Merged
merged 3 commits into from
Aug 28, 2024

Conversation

antazoey
Copy link
Member

What I did

Ape shows you all compiler errors across compilers.
That is great, except when there was only a single error, thus causing a pointless exception being thrown on the stack.

How I did it

if len(errors) is just 1, just raise that error instead.

How to verify it

Compile with 1 compiler failing - should just see the custom
Compile with 2 compilers failing - should see them amassed

I added tests for both of these cases.

Checklist

  • All changes are completed
  • New test cases have been added
  • Documentation has been updated

fubuloubu
fubuloubu previously approved these changes Aug 27, 2024
raise errors[0]

elif len(errors) > 1:
# Raise a combined error.
formatted_errors = [f"{e}" for e in errors]
error_message = "\n\n".join(formatted_errors)
raise CompilerError(error_message)
Copy link
Member

Choose a reason for hiding this comment

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

Wonder if python 3.11+ exception groups make sense to use when it becomes available to us

Copy link
Member Author

Choose a reason for hiding this comment

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

Wow this is cool!

Idea: could try to work this in for the Python versions that support it and have it the dumb way now

@antazoey antazoey merged commit bba268c into ApeWorX:main Aug 28, 2024
16 checks passed
@antazoey antazoey deleted the fix/raise-single-error-if-only-1 branch August 28, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants