Skip to content

Commit

Permalink
prettify error message for catch-all conflict with existing path segm…
Browse files Browse the repository at this point in the history
…ent (#2934)
  • Loading branch information
SericaLaw committed Nov 28, 2021
1 parent f068099 commit a06d546
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,12 @@ func (n *node) insertChild(path string, fullPath string, handlers HandlersChain)
}

if len(n.path) > 0 && n.path[len(n.path)-1] == '/' {
panic("catch-all conflicts with existing handle for the path segment root in path '" + fullPath + "'")
pathSeg := strings.SplitN(n.children[0].path, "/", 2)[0]
panic("catch-all wildcard '" + path +
"' in new path '" + fullPath +
"' conflicts with existing path segment '" + pathSeg +
"' in existing prefix '" + n.path + pathSeg +
"'")
}

// currently fixed width 1 for '/'
Expand Down

0 comments on commit a06d546

Please sign in to comment.