Skip to content

Commit

Permalink
-fixed bug where error was logged instead of panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
tiger5226 committed May 8, 2018
1 parent 29b7851 commit 19e4acc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions daemon/jobs/claimtriesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/lbryio/chainquery/lbrycrd"
"github.com/lbryio/chainquery/model"
"github.com/lbryio/chainquery/util"
"github.com/lbryio/errors.go"

"github.com/sirupsen/logrus"
"github.com/volatiletech/sqlboiler/queries/qm"
Expand Down Expand Up @@ -238,18 +239,19 @@ func getClaimTrieSyncJobStatus() (*model.JobStatus, error) {
if jobStatus == nil {
jobStatus = &model.JobStatus{JobName: claimTrieSyncJob, LastSync: time.Time{}}
if err := jobStatus.InsertG(); err != nil {
return nil, err
logrus.Panic("Cannot Retrieve/Create JobStatus for " + claimTrieSyncJob)
}
}

return jobStatus, nil
}

func saveJobError(jobStatus *model.JobStatus, err error) {
jobStatus.ErrorMessage.String = err.Error()
func saveJobError(jobStatus *model.JobStatus, error error) {
jobStatus.ErrorMessage.String = error.Error()
jobStatus.ErrorMessage.Valid = true
jobStatus.IsSuccess = false
cols := model.JobStatusColumns
if err := jobStatus.UpsertG([]string{cols.JobName, cols.LastSync, cols.IsSuccess, cols.ErrorMessage}); err != nil {
logrus.Error(err)
if err := jobStatus.UpsertG([]string{cols.JobName, cols.IsSuccess, cols.ErrorMessage}); err != nil {
logrus.Error(errors.Prefix("Saving Job Error Message "+error.Error(), err))
}
}

0 comments on commit 19e4acc

Please sign in to comment.