Skip to content

Commit

Permalink
Merge pull request #253 from mergestat/summarize-error-handling
Browse files Browse the repository at this point in the history
fix: error handling for summarize commands
  • Loading branch information
patrickdevivo authored Feb 15, 2022
2 parents adbc040 + 3094f5c commit 7e5a991
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion cmd/summarize/blame/blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,5 +467,9 @@ func (t *TermUI) PrintJSON() string {
}

func (t *TermUI) Close() error {
return t.db.Close()
defer t.db.Close()
if t.err != nil {
return t.err
}
return nil
}
6 changes: 5 additions & 1 deletion cmd/summarize/commits/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,5 +435,9 @@ func (t *TermUI) PrintJSON() string {
}

func (t *TermUI) Close() error {
return t.db.Close()
defer t.db.Close()
if t.err != nil {
return t.err
}
return nil
}
6 changes: 5 additions & 1 deletion cmd/summarize_blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ Use '%' to match all file paths or as a wildcard (e.g. '%.go' for all .go files)
if ui, err = blame.NewTermUI(pathPattern); err != nil {
handleExitError(err)
}
defer ui.Close()
defer func() {
if err := ui.Close(); err != nil {
handleExitError(err)
}
}()

if blameOutputJSON {
fmt.Println(ui.PrintJSON())
Expand Down
6 changes: 5 additions & 1 deletion cmd/summarize_commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ Read more here: https://sqlite.org/lang_expr.html#the_like_glob_regexp_and_match
if ui, err = commits.NewTermUI(pathPattern, summarizeDateFilterStart, summarizeDateFilterEnd); err != nil {
handleExitError(err)
}
defer ui.Close()
defer func() {
if err := ui.Close(); err != nil {
handleExitError(err)
}
}()

if summarizeOutputJSON {
fmt.Println(ui.PrintJSON())
Expand Down

0 comments on commit 7e5a991

Please sign in to comment.