VOL-1925 Method-router unit tests;
return errors on invalid ReplyHandler calls
return error and print error messages in Route calls
Change-Id: I846801d1ff403c02b8e1326061c37629fef83838
diff --git a/afrouter/afrouter/method-router.go b/afrouter/afrouter/method-router.go
index 56d025e..2916edf 100644
--- a/afrouter/afrouter/method-router.go
+++ b/afrouter/afrouter/method-router.go
@@ -168,12 +168,10 @@
if r, ok := mr.methodRouter[NoMeta][sl.method]; ok {
return r.ReplyHandler(sel)
}
- // TODO: this case should also be an error
- default: //TODO: This should really be a big error
- // A reply handler should only be called on the responseFrame
- return nil
+ return errors.New("MethodRouter.ReplyHandler called with unknown meta or method")
+ default:
+ return errors.New("MethodRouter.ReplyHandler called with non-reponseFrame")
}
- return nil
}
func (mr MethodRouter) Route(sel interface{}) (*backend, *connection) {
@@ -182,9 +180,11 @@
if r, ok := mr.methodRouter[sl.metaKey][sl.methodInfo.method]; ok {
return r.Route(sel)
}
- log.Errorf("Attept to route on non-existent method '%s'", sl.methodInfo.method)
+ sl.err = fmt.Errorf("MethodRouter.Route unable to resolve meta %s, method %s", sl.metaKey, sl.methodInfo.method)
+ log.Error(sl.err)
return nil, nil
default:
+ log.Errorf("Internal: invalid data type in Route call %v", sel)
return nil, nil
}
}