From 66a9140c206dd108374c293d687cd1bbf27f0e8b Mon Sep 17 00:00:00 2001 From: "Matt T. Proud" Date: Fri, 5 May 2017 22:31:10 +0200 Subject: [PATCH] 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. --- server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server.go b/server.go index 8bae2985..0d17e784 100644 --- a/server.go +++ b/server.go @@ -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 }