Skip to content

Commit

Permalink
fix: flush sentry events before exiting
Browse files Browse the repository at this point in the history
Signed-off-by: Siddhant N Trivedi <siddhant@deepsource.io>
  • Loading branch information
siddhant-deepsource committed Mar 1, 2022
1 parent 4178196 commit 4e81080
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/deepsource/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"log"
"os"
"time"

"github.com/deepsourcelabs/cli/command"
v "github.com/deepsourcelabs/cli/version"
Expand All @@ -22,7 +23,6 @@ var (
)

func main() {

log.SetFlags(log.LstdFlags | log.Lshortfile)

// Init sentry
Expand All @@ -38,6 +38,7 @@ func main() {
// TODO: Handle exit codes here
pterm.Error.Println(err)
sentry.CaptureException(err)
sentry.Flush(2 * time.Second)
os.Exit(1)
}
}
2 changes: 2 additions & 0 deletions command/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"strings"
"time"

"github.com/deepsourcelabs/cli/utils"
"github.com/getsentry/sentry-go"
Expand All @@ -30,6 +31,7 @@ func NewCmdReport() *cobra.Command {
Args: utils.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
returnCode := opts.Run()
sentry.Flush(2 * time.Second)
defer os.Exit(returnCode)
},
}
Expand Down

0 comments on commit 4e81080

Please sign in to comment.