fix: record last error when calling `processDir`

pull/100/head
鲁树人 2 months ago
parent 2afc232eb1
commit 36df203bdd

@ -231,6 +231,8 @@ func (p *processor) processDir(inputDir string) error {
if err != nil { if err != nil {
return err return err
} }
var lastError error = nil
for _, item := range items { for _, item := range items {
if item.IsDir() { if item.IsDir() {
continue continue
@ -238,9 +240,13 @@ func (p *processor) processDir(inputDir string) error {
filePath := filepath.Join(inputDir, item.Name()) filePath := filepath.Join(inputDir, item.Name())
if err := p.processFile(filePath); err != nil { if err := p.processFile(filePath); err != nil {
lastError = err
logger.Error("conversion failed", zap.String("source", item.Name()), zap.Error(err)) logger.Error("conversion failed", zap.String("source", item.Name()), zap.Error(err))
} }
} }
if lastError != nil {
return fmt.Errorf("last error: %w", lastError)
}
return nil return nil
} }

Loading…
Cancel
Save