More helpful message when failing to match
Closed this issue · 1 comments
clawconduce commented
I added something like this to help me debug a problem I was having:
diff --git a/github.com/rafaeljusto/redigomock/redigomock.go b/github.com/rafaeljusto/redigomo
index 112fc33..aadd5ab 100644
--- a/github.com/rafaeljusto/redigomock/redigomock.go
+++ b/github.com/rafaeljusto/redigomock/redigomock.go
@@ -152,6 +152,11 @@ func (c *Conn) Do(commandName string, args ...interface{}) (reply interface{}, e
if cmd == nil {
// Didn't find a specific command, try to get a generic one
if cmd = c.find(commandName, nil); cmd == nil {
+ for _, regCmd := range c.commands {
+ if commandName == regCmd.Name {
+ fmt.Printf("%s possible match for\n%#v:\n%#v", commandName, args, regCmd.Args)
+ }
+ }
return nil, fmt.Errorf("command %s with arguments %#v not registered in redigomock library",
commandName, args)
}
It is pretty hacky, but I think something like this would be useful either in the error msg or printed out to screen.
rafaeljusto commented
I don't like too much the idea of a library printing into the stdout. Maybe we could improve the error message to add this suggestions.