report serde parse errors to stderr

This commit is contained in:
rleungx
2018-04-19 22:55:47 +08:00
parent 43e6741071
commit 60015aee04
5 changed files with 36 additions and 10 deletions

View File

@@ -33,10 +33,12 @@ fn main() {
}
let addr = format!("0.0.0.0:{}", port);
let stdin = io::stdin();
let mut entries = stdin
.lock()
.lines()
.map(|line| serde_json::from_str(&line.unwrap()).unwrap());
let mut entries = stdin.lock().lines().map(|line| {
serde_json::from_str(&line.unwrap()).unwrap_or_else(|e| {
eprintln!("failed to parse json: {}", e);
exit(1);
})
});
// The first item in the ledger is required to be an entry with zero num_hashes,
// which implies its id can be used as the ledger's seed.