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

Propagate error message to user on systemexit #2058

Merged
merged 1 commit into from Apr 6, 2022

Conversation

wbh1
Copy link
Contributor

@wbh1 wbh1 commented Mar 31, 2022

A previous PR added 'raise x from y" syntax, but consequently stopped raising
the useful error message content up the stack to the user.

This keeps the 'raise from' syntax, but just adds the error message back in.

Fixes: #2057

A previous PR added 'raise x from y" syntax, but consequently stopped raising
the useful error message content up the stack to the user.

This keeps the 'raise from' syntax, but just adds the error message back in.
@github-actions github-actions bot added the bug label Mar 31, 2022
@ssbarnea
Copy link
Member

ssbarnea commented Apr 6, 2022

My impression was that raise x from y was keeping that information. Is there something special about SystemExit that makes it fail to do so?

Can someone include a link about this? I am asking as I want to read more about the subject and avoid similar problem in the future.

@wbh1
Copy link
Contributor Author

wbh1 commented Apr 6, 2022

@ssbarnea it's because SystemExit doesn't print out a traceback [1], which is when __cause__ is actually used.

raise x from y sets the __cause__ variable on an object inheriting from BaseException. That __cause__ is used for chaining exceptions in the traceback printed to console [2], but since SystemExit never displays a stacktrace the __cause__ never ends up mattering.

I put this gist together to show the different behaviors.

@ssbarnea ssbarnea changed the title fix: propagate error message to user Propagate error message to user on systemexit Apr 6, 2022
@ssbarnea ssbarnea merged commit 5df5e50 into ansible:main Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid task file syntax in imported tasks prevents all non-playbook checks from running
3 participants