1
0
mirror of https://github.com/go-task/task.git synced 2025-11-23 22:24:45 +02:00

feat: better error handling for duplicate edges and fixed tests

This commit is contained in:
Pete Davison
2023-09-05 23:55:56 +00:00
parent a50580b5a1
commit 0a027df50d
9 changed files with 52 additions and 18 deletions

View File

@@ -141,7 +141,19 @@ func (r *Reader) include(node Node) error {
}
// Create an edge between the Taskfiles
return r.graph.AddEdge(node.Location(), includeNode.Location())
err = r.graph.AddEdge(node.Location(), includeNode.Location())
if errors.Is(err, graph.ErrEdgeAlreadyExists) {
edge, err := r.graph.Edge(node.Location(), includeNode.Location())
if err != nil {
return err
}
return &errors.TaskfileDuplicateIncludeError{
URI: node.Location(),
IncludedURI: includeNode.Location(),
Namespaces: []string{namespace, edge.Properties.Data.(*ast.Include).Namespace},
}
}
return err
})
return nil
})