Skip to content

Commit

Permalink
feat(kernel): log traversal error (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Sep 8, 2024
1 parent 39b6d60 commit ff4bff2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/kernel/mediator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package kernel

import (
"context"
"errors"
"io/fs"

"github.com/snivilised/traverse/core"
"github.com/snivilised/traverse/cycle"
Expand Down Expand Up @@ -104,6 +106,10 @@ func (m *mediator) Navigate(ctx context.Context) (core.TraverseResult, error) {
root: m.root,
})

if !IsBenignError(err) {
m.o.Monitor.Log.Error(err.Error())
}

return result, err
}

Expand All @@ -127,3 +133,11 @@ func (m *mediator) Supervisor() *measure.Supervisor {
func (m *mediator) Controls() *cycle.Controls {
return &m.o.Binder.Controls
}

func IsBenignError(err error) bool {
if err == nil {
return true
}

return errors.Is(err, fs.SkipDir) || errors.Is(err, fs.SkipAll)
}

0 comments on commit ff4bff2

Please sign in to comment.