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

ledger-tool: Condense repeated error handling #34439

Merged
merged 5 commits into from
Dec 13, 2023

Conversation

steviez
Copy link
Contributor

@steviez steviez commented Dec 13, 2023

This PR is a split out from #34426

Problem

Several commands call load_and_process_ledger() which can fail in a number of ways. These callers currently all handle the result in the same way by matching the return Result:

  • The Ok(_) case uses the returned types as normal
  • The Err(_) case prints an error message and exits

This error handling is redundant, and a helper could remove the duplicate code

Summary of Changes

  • Introduce load_and_process_ledger_or_exit(), a wrapper for load_and_process_ledger() that unwraps OR prints an error message and returns for Err
  • Use the new load_and_process_ledger_or_exit() in all previous callers of load_and_process_ledger()
  • Run cargo fmt to remove the level of indentation from previous callers

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Merging #34439 (5539739) into master (a04ab94) will increase coverage by 0.0%.
Report is 5 commits behind head on master.
The diff coverage is 100.0%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #34439   +/-   ##
=======================================
  Coverage    81.8%    81.9%           
=======================================
  Files         819      819           
  Lines      220936   220931    -5     
=======================================
+ Hits       180936   180955   +19     
+ Misses      40000    39976   -24     

@steviez steviez marked this pull request as ready for review December 13, 2023 17:41
Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

lgtm

@steviez steviez merged commit 2a67fa8 into solana-labs:master Dec 13, 2023
34 checks passed
@steviez steviez deleted the lt_condense_exits_pt2 branch December 13, 2023 20:50
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