Skip to content

Commit

Permalink
make ServerOption panic messages more clear. (#1194)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matttproud authored and menghanl committed May 5, 2017
1 parent f3b5bf5 commit 66a9140
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 66a9140

Please sign in to comment.