Skip to content

Commit

Permalink
Add logger
Browse files Browse the repository at this point in the history
  • Loading branch information
pastuxso committed Aug 7, 2024
1 parent cf6eac8 commit bef639d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ func (p *Project) loadFromDirectory(
err := util.Walk(p.fs, ".", func(path string, info fs.FileInfo, err error) error {
if err != nil {
if errors.Is(err, os.ErrPermission) {
p.logger.Warn("permission denied", zap.String("path", path), zap.Error(err))
if info.IsDir() {
return filepath.SkipDir
}
Expand Down Expand Up @@ -461,6 +462,11 @@ func (p *Project) extractTasksFromFile(
})

if err != nil {
if errors.Is(err, os.ErrPermission) {
p.logger.Warn("permission denied", zap.String("path", path), zap.Error(err))
return
}

p.send(ctx, eventc, LoadEvent{
Type: LoadEventError,
Data: LoadEventErrorData{Err: err},
Expand Down Expand Up @@ -489,9 +495,6 @@ func (p *Project) extractTasksFromFile(
func getCodeBlocksFromFile(path string) (document.CodeBlocks, error) {
data, err := os.ReadFile(path)
if err != nil {
if errors.Is(err, os.ErrPermission) {
return document.CodeBlocks{}, nil
}
return nil, err
}
return getCodeBlocks(data)
Expand Down

0 comments on commit bef639d

Please sign in to comment.