Error implements error interface
()
| 125 | |
| 126 | // Error implements error interface |
| 127 | func (c *CyclicError) Error() string { |
| 128 | cycle := []string{getNameOrID(c.path[len(c.path)-1])} |
| 129 | |
| 130 | for _, node := range c.path { |
| 131 | cycle = append(cycle, getNameOrID(node)) |
| 132 | } |
| 133 | |
| 134 | what := "dependency" |
| 135 | if c.What != "" { |
| 136 | what = c.What |
| 137 | } |
| 138 | |
| 139 | return fmt.Sprintf("Cyclic %s found: \n%s", what, strings.Join(cycle, "\n")) |
| 140 | } |
| 141 | |
| 142 | // AddEdge adds a new edge from a node to a node and returns an error if it would result in a cyclic graph |
| 143 | func (g *Graph) AddEdge(fromID string, toID string) error { |