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
  • Loading branch information
SericaLaw authored and daheige committed Apr 18, 2022
1 parent bf130b5 commit 6f0eec5
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 6f0eec5

Please sign in to comment.