routines: Manager handles errors far better now

This commit is contained in:
Sasha Koshka 2024-11-19 17:21:21 -05:00
parent 55904642d0
commit 85a71fda60

View File

@ -88,7 +88,7 @@ func (this *Manager) Run (ctx context.Context) error {
waitGroup.Wait()
done()
return nil
return ctx.Err()
}
// Append adds one or more routines to the Routines slice. This has no effect if
@ -134,7 +134,7 @@ func (this *Manager) runRoutine (routine Routine, group *sync.WaitGroup) {
err := panicWrap(routine.Run, this.ctx)
if ctxErr := this.ctx.Err(); ctxErr != nil {
if err == nil {
if err == nil || errors.Is(err, context.Canceled) {
this.log("(i) stopped routine")
} else {
this.log("!!! stopped routine, with error:", err)