Skip to content

Commit

Permalink
Merge pull request #81 from vgonkivs/change_error_to_string
Browse files Browse the repository at this point in the history
bug(sync): change error type to string
  • Loading branch information
vgonkivs committed Jul 11, 2023
2 parents 1ce71fd + 7aa2164 commit b7f7ed0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ type State struct {
FromHeight, ToHeight uint64 // the starting and the ending point of a sync
FromHash, ToHash header.Hash
Start, End time.Time
Error error // the error that might happen within a sync
Error string // the error that might happen within a sync
}

// Finished returns true if sync is done, false otherwise.
Expand All @@ -147,9 +147,9 @@ func (s *Syncer[H]) State() State {
head, err := s.store.Head(s.ctx)
if err == nil {
state.Height = uint64(head.Height())
} else if state.Error == nil {
} else if state.Error == "" {
// don't ignore the error if we can show it in the state
state.Error = err
state.Error = err.Error()
}

return state
Expand Down Expand Up @@ -238,7 +238,9 @@ func (s *Syncer[H]) doSync(ctx context.Context, fromHead, toHead H) (err error)

s.stateLk.Lock()
s.state.End = time.Now()
s.state.Error = err
if err != nil {
s.state.Error = err.Error()
}
s.stateLk.Unlock()
return err
}
Expand Down

0 comments on commit b7f7ed0

Please sign in to comment.