make ServerOption panic messages more clear. (#1194)

ServerOption panics when fields that have been manually set are
subsequently set again.  The message verbiage of `X has been set` is
unclear since `has been set` without an adverb like `already` does not
correctly convey that the fields are set-once and were previously set.
At the worst, the original verbiage `X has been set` could imply that
the new value would have been acceptable but another error occurred.

We discovered this while conducting a code survey for implementing
extensible stubs and uniform inbound interception API.
This commit is contained in:
Matt T. Proud 2017-05-05 22:31:10 +02:00 committed by Menghan Li
parent f3b5bf53ce
commit 66a9140c20
1 changed files with 3 additions and 3 deletions

View File

@ -210,7 +210,7 @@ func Creds(c credentials.TransportCredentials) ServerOption {
func UnaryInterceptor(i UnaryServerInterceptor) ServerOption {
return func(o *options) {
if o.unaryInt != nil {
panic("The unary server interceptor has been set.")
panic("The unary server interceptor was already set and may not be reset.")
}
o.unaryInt = i
}
@ -221,7 +221,7 @@ func UnaryInterceptor(i UnaryServerInterceptor) ServerOption {
func StreamInterceptor(i StreamServerInterceptor) ServerOption {
return func(o *options) {
if o.streamInt != nil {
panic("The stream server interceptor has been set.")
panic("The stream server interceptor was already set and may not be reset.")
}
o.streamInt = i
}
@ -232,7 +232,7 @@ func StreamInterceptor(i StreamServerInterceptor) ServerOption {
func InTapHandle(h tap.ServerInHandle) ServerOption {
return func(o *options) {
if o.inTapHandle != nil {
panic("The tap handle has been set.")
panic("The tap handle was already set and may not be reset.")
}
o.inTapHandle = h
}