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

Adding try/except when running cli to remove stack traces #73

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

valefar-on-discord
Copy link
Collaborator

Instead of showing a massive stack trace for thrown errors, we will now wrap the cli() call and catch and ValidatorError or ValueError and then display what the error is.

To reproduce a stack traced ValidationError:

python3 -m ethstaker_deposit --non_interactive --language english existing-mnemonic --mnemonic="1234 4321 1234"

To reproduce a stack traced ValueError:

python3 -m ethstaker_deposit --language english --non_interactive generate-bls-to-execution-change --mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" --chain="mainnet" --validator_start_index=0 --validator_indices="1 2" --bls_withdrawal_credentials_list=00245ac28e1ed7eb69d62af7bfbde0e154e749eaf80e208e947dde4c1ed236ad --execution_address="0x00000000219ab540356cBB839Cbe05303d7705Fa"

Fixes #18

Copy link
Member

@remyroy remyroy left a comment

Choose a reason for hiding this comment

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

Some small improvements are needed. Let me know what you think.

try:
cli()
except (ValueError, ValidationError) as e:
click.echo(f"\nError: {e}\n")
Copy link
Member

@remyroy remyroy Jun 25, 2024

Choose a reason for hiding this comment

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

The call to click.echo should include the following parameter here: err=True since this is an error. See https://click.palletsprojects.com/en/7.x/api/#click.echo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ack

ethstaker_deposit/deposit.py Show resolved Hide resolved
sys.exit(1) if catch called
Copy link
Member

@remyroy remyroy left a comment

Choose a reason for hiding this comment

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

All good!

@remyroy remyroy merged commit 5b57b7b into eth-educators:main Jun 26, 2024
15 checks passed
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.

Rework ValidationError and replace the related traceback with a nice error message
2 participants