refactor: add missing defers and handle error returned by bot.Run gracefully
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
23b3da14a5
commit
c15cafc1d7
|
@ -37,6 +37,9 @@ func New() *cli.Command {
|
|||
if err != nil {
|
||||
return fmt.Errorf("internal.NewBunDB: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
_ = db.Close()
|
||||
}()
|
||||
|
||||
client, err := internal.NewTWHelpClient(c.App.Version)
|
||||
if err != nil {
|
||||
|
@ -67,7 +70,12 @@ func New() *cli.Command {
|
|||
}
|
||||
|
||||
go func() {
|
||||
_ = bot.Run()
|
||||
if runErr := bot.Run(); runErr != nil {
|
||||
logger.Fatal("bot.Run: " + runErr.Error())
|
||||
}
|
||||
}()
|
||||
defer func() {
|
||||
_ = bot.Close()
|
||||
}()
|
||||
|
||||
if err = os.WriteFile(healthyFilePath, []byte("healthy"), healthyFilePerm); err != nil {
|
||||
|
@ -78,10 +86,6 @@ func New() *cli.Command {
|
|||
|
||||
waitForSignal(c.Context)
|
||||
|
||||
if err = bot.Close(); err != nil {
|
||||
return fmt.Errorf("bot.Close: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user