Skip to content

Commit 04d2680

Browse files
committed
Handle error from the file watcher
1 parent 55cc22f commit 04d2680

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

timefor.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ func Daemon(
540540
select {
541541
case c := <-change:
542542
log.Println("change", c)
543+
if c.Error != nil {
544+
return c.Error
545+
}
543546

544547
case <-time.After(nextUpdate):
545548
if activity.Active() && time.Since(activity.Updated()) > time.Minute {
@@ -680,14 +683,6 @@ func Report(db *sqlx.DB) (title, desc string, err error) {
680683
return title, buf.String(), nil
681684
}
682685

683-
func formatDuration(d time.Duration) string {
684-
d = d.Truncate(time.Minute)
685-
h := d / time.Hour
686-
d -= h * time.Hour
687-
m := d / time.Minute
688-
return fmt.Sprintf("%02d:%02d", h, m)
689-
}
690-
691686
// Select selects new activity using rofi menu
692687
func Select(db *sqlx.DB) (string, error) {
693688
var names []string
@@ -726,6 +721,14 @@ func Select(db *sqlx.DB) (string, error) {
726721
return string(selectedName), nil
727722
}
728723

724+
func formatDuration(d time.Duration) string {
725+
d = d.Truncate(time.Minute)
726+
h := d / time.Hour
727+
d -= h * time.Hour
728+
m := d / time.Minute
729+
return fmt.Sprintf("%02d:%02d", h, m)
730+
}
731+
729732
// Activity represents a named activity
730733
type Activity struct {
731734
ID int64

0 commit comments

Comments
 (0)