Skip to content

Commit

Permalink
chore: improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Jan 18, 2024
1 parent a256049 commit 222df4d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,12 @@ func (svc *Service) GetInfo() *api.InfoResponse {
func (svc *Service) Setup(setupRequest *api.SetupRequest) error {

dbConfig := db.Config{}
svc.db.First(&dbConfig)
err := svc.db.First(&dbConfig).Error

if err != nil {
svc.Logger.Errorf("Failed to get db config: %v", err)
return err
}

// only update non-empty values
if setupRequest.LNBackendType != "" {
Expand Down Expand Up @@ -250,11 +255,11 @@ func (svc *Service) Setup(setupRequest *api.SetupRequest) error {
dbConfig.LNDMacaroonHex = setupRequest.LNDMacaroonHex
}

res := svc.db.Save(&dbConfig)
err = svc.db.Save(&dbConfig).Error

if res.Error != nil {
svc.Logger.Errorf("Failed to update config: %v", res.Error)
return res.Error
if err != nil {
svc.Logger.Errorf("Failed to update config: %v", err)
return err
}

return svc.launchLNBackend()
Expand Down

0 comments on commit 222df4d

Please sign in to comment.