mirror of
https://github.com/golang/go.git
synced 2025-05-29 11:25:43 +00:00
net/rpc: improve error report messages
Updates #19957 Change-Id: I8e2e3837db9e5e69b7102f9bd5831fe78ac60cfc Reviewed-on: https://go-review.googlesource.com/87335 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
9f31353a6c
commit
a89fa7040b
@ -296,7 +296,7 @@ func suitableMethods(typ reflect.Type, reportErr bool) map[string]*methodType {
|
|||||||
// Method needs three ins: receiver, *args, *reply.
|
// Method needs three ins: receiver, *args, *reply.
|
||||||
if mtype.NumIn() != 3 {
|
if mtype.NumIn() != 3 {
|
||||||
if reportErr {
|
if reportErr {
|
||||||
log.Println("method", mname, "has wrong number of ins:", mtype.NumIn())
|
log.Printf("rpc.Register: method %q has %d input parameters; needs exactly three\n", mname, mtype.NumIn())
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ func suitableMethods(typ reflect.Type, reportErr bool) map[string]*methodType {
|
|||||||
argType := mtype.In(1)
|
argType := mtype.In(1)
|
||||||
if !isExportedOrBuiltinType(argType) {
|
if !isExportedOrBuiltinType(argType) {
|
||||||
if reportErr {
|
if reportErr {
|
||||||
log.Println(mname, "argument type not exported:", argType)
|
log.Printf("rpc.Register: argument type of method %q is not exported: %q\n", mname, argType)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -312,28 +312,28 @@ func suitableMethods(typ reflect.Type, reportErr bool) map[string]*methodType {
|
|||||||
replyType := mtype.In(2)
|
replyType := mtype.In(2)
|
||||||
if replyType.Kind() != reflect.Ptr {
|
if replyType.Kind() != reflect.Ptr {
|
||||||
if reportErr {
|
if reportErr {
|
||||||
log.Println("method", mname, "reply type not a pointer:", replyType)
|
log.Printf("rpc.Register: reply type of method %q is not a pointer: %q\n", mname, replyType)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Reply type must be exported.
|
// Reply type must be exported.
|
||||||
if !isExportedOrBuiltinType(replyType) {
|
if !isExportedOrBuiltinType(replyType) {
|
||||||
if reportErr {
|
if reportErr {
|
||||||
log.Println("method", mname, "reply type not exported:", replyType)
|
log.Printf("rpc.Register: reply type of method %q is not exported: %q\n", mname, replyType)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Method needs one out.
|
// Method needs one out.
|
||||||
if mtype.NumOut() != 1 {
|
if mtype.NumOut() != 1 {
|
||||||
if reportErr {
|
if reportErr {
|
||||||
log.Println("method", mname, "has wrong number of outs:", mtype.NumOut())
|
log.Printf("rpc.Register: method %q has %d output parameters; needs exactly one\n", mname, mtype.NumOut())
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// The return type of the method must be error.
|
// The return type of the method must be error.
|
||||||
if returnType := mtype.Out(0); returnType != typeOfError {
|
if returnType := mtype.Out(0); returnType != typeOfError {
|
||||||
if reportErr {
|
if reportErr {
|
||||||
log.Println("method", mname, "returns", returnType.String(), "not error")
|
log.Printf("rpc.Register: return type of method %q is %q, must be error\n", mname, returnType)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user