Skip to content

Commit

Permalink
Merge pull request #8720 from MinaProtocol/feature/error-code-export-…
Browse files Browse the repository at this point in the history
…staking

Exit with code 1 if there is an error in `ledger export`
  • Loading branch information
mrmr1993 authored Apr 27, 2021
2 parents b8b7828 + ccdfe23 commit b5aebf5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/app/cli/src/init/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -892,17 +892,20 @@ let dump_keypair =

let handle_export_ledger_response ~json = function
| Error e ->
Daemon_rpcs.Client.print_rpc_error e
Daemon_rpcs.Client.print_rpc_error e ;
exit 1
| Ok (Error e) ->
printf !"Ledger not found: %s\n" (Error.to_string_hum e)
printf !"Ledger not found: %s\n" (Error.to_string_hum e) ;
exit 1
| Ok (Ok accounts) ->
if json then (
Yojson.Safe.pretty_print Format.std_formatter
(Runtime_config.Accounts.to_yojson
(List.map accounts ~f:(fun a ->
Genesis_ledger_helper.Accounts.Single.of_account a None ))) ;
printf "\n" )
else printf !"%{sexp:Account.t list}\n" accounts
else printf !"%{sexp:Account.t list}\n" accounts ;
return ()

let export_ledger =
let state_hash_flag =
Expand Down Expand Up @@ -956,7 +959,7 @@ let export_ledger =
(* unreachable *)
failwithf "Unknown ledger kind: %s" ledger_kind ()
in
response >>| handle_export_ledger_response ~json:(not plaintext) ))
response >>= handle_export_ledger_response ~json:(not plaintext) ))

let hash_ledger =
let open Command.Let_syntax in
Expand Down

0 comments on commit b5aebf5

Please sign in to comment.