Skip to content

Commit

Permalink
chore: better error print (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li authored Jun 1, 2023
1 parent 77eb039 commit f04c89b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cli/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl<'a> FormatDisplay<'a> {
println!("\n{}\n", format_sql);
}
let mut rows = Vec::new();
let mut error = None;
while let Some(line) = self.data.next().await {
match line {
Ok(RowWithProgress::Row(row)) => {
Expand All @@ -96,20 +97,25 @@ impl<'a> FormatDisplay<'a> {
self.stats = Some(pg);
}
Err(err) => {
eprintln!("error: {}", err);
error = Some(err);
break;
}
}
}
if let Some(pb) = self.progress.take() {
pb.finish_and_clear();
}

if !rows.is_empty() {
println!(
"{}",
create_table(self.schema.clone(), &rows, self.settings.max_display_rows)?
);
}

if let Some(err) = error {
eprintln!("error happens after fetched {} rows: {}", rows.len(), err);
}
Ok(())
}

Expand Down

0 comments on commit f04c89b

Please sign in to comment.