mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 09:57:01 +00:00
fix #1665
This commit is contained in:
@@ -248,8 +248,29 @@ func getBindingsForFunc(fn reflect.Value, dependencies []*Dependency, paramsCoun
|
||||
}
|
||||
|
||||
bindings := getBindingsFor(inputs, dependencies, paramsCount)
|
||||
if expected, got := n, len(bindings); expected > got {
|
||||
panic(fmt.Sprintf("expected [%d] bindings (input parameters) but got [%d]", expected, got))
|
||||
if expected, got := n, len(bindings); expected != got {
|
||||
expectedInputs := ""
|
||||
missingInputs := ""
|
||||
for i, in := range inputs {
|
||||
pos := i + 1
|
||||
typName := in.String()
|
||||
expectedInputs += fmt.Sprintf("\n - [%d] %s", pos, typName)
|
||||
found := false
|
||||
for _, b := range bindings {
|
||||
if b.Input.Index == i {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
missingInputs += fmt.Sprintf("\n - [%d] %s", pos, typName)
|
||||
}
|
||||
}
|
||||
|
||||
fnName := context.HandlerName(fn)
|
||||
panic(fmt.Sprintf("expected [%d] bindings (input parameters) but got [%d]\nFunction:\n - %s\nExpected:%s\nMissing:%s",
|
||||
expected, got, fnName, expectedInputs, missingInputs))
|
||||
}
|
||||
|
||||
return bindings
|
||||
|
||||
Reference in New Issue
Block a user