@@ -73,10 +73,20 @@ func (r *Router) Dispatch(method, pattern string, fn func(d *DispatchBuilder, m
7373
7474 // Conflict checks — catch problems early rather than letting chi panic
7575 if _ , exists := r .dispatchers [dispatcherKey ]; exists {
76- panic (fmt .Sprintf ("teapot: Dispatch conflicts with existing dispatcher for %s %s" , method , fullPattern ))
76+ panic (fmt .Sprintf (
77+ "teapot: duplicate dispatch registration\n \n " +
78+ " route: %s %s\n " +
79+ " cause: a Dispatch() or query-multiplexed route already owns this method+pattern\n " +
80+ " help: consolidate all variants for this route into a single Dispatch() block" ,
81+ method , fullPattern ))
7782 }
7883 if _ , exists := r .directRoutes [dispatcherKey ]; exists {
79- panic (fmt .Sprintf ("teapot: Dispatch conflicts with existing direct route for %s %s" , method , fullPattern ))
84+ panic (fmt .Sprintf (
85+ "teapot: duplicate route registration\n \n " +
86+ " route: %s %s\n " +
87+ " cause: a direct route (GET, POST, etc.) is already registered for this method+pattern\n " +
88+ " help: remove the direct route, or replace both with a single Dispatch() block" ,
89+ method , fullPattern ))
8090 }
8191
8292 db := & DispatchBuilder {
@@ -91,7 +101,12 @@ func (r *Router) Dispatch(method, pattern string, fn func(d *DispatchBuilder, m
91101 // Validate that every route has a handler set
92102 for _ , cfg := range db .routes {
93103 if cfg .handler == nil {
94- panic ("teapot: Dispatch route missing handler — call Do() or pass handler to Default()" )
104+ panic (fmt .Sprintf (
105+ "teapot: invalid dispatch route %q (%s): no handler configured\n " +
106+ "hint: call Do(...) for this route or provide a handler via Default(...)" ,
107+ cfg .name ,
108+ cfg .action ,
109+ ))
95110 }
96111 }
97112
0 commit comments